rhoadley.net   music   research   software   blogs

aru    seminars    m&t    critski    focm1a    cmc    circuit bending    mic2b    sensor technology    comp 3    sonic art    major project
youtube    vimeo    facebook


Resources:    Bioacoustics    Jitter    MaxMSP    OSC    Physical    PD       CBHH    sTech    SuperCollider    C/Xcode

sTech Resources:     Home     Blog     Forum     Examples     Projects     Tasks     Tutorials


Sensor Technology Tasks

Arduino Task 1

Task 1 Name: "Hello world!" Set: w1i Due: Monday 19th December 2016 Weighting: 0% Courses: stech
Task Summary All sTech tasks

Blink

"Hello World" for the Arduino - YouTube video of this exercise!

NB if you've decided to use another type of board, as long as you get a basically similar result, that's fine. We've looking here at simply familiarising yourself with the system of programming and editing.

Code for Processing/Arduino


/*
 * Blink
 *
 * The basic Arduino example.  Turns on an LED on for one second,
 * then off for one second, and so on...  We use pin 13 because,
 * depending on your Arduino board, it has either a built-in LED
 * or a built-in resistor so that you need only an LED.
 *
 * http://www.arduino.cc/en/Tutorial/Blink
 */

int ledPin = 13;                // LED connected to digital pin 13

void setup()                    // run once, when the sketch starts
{
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
}

void loop()                     // run over and over again
{
  digitalWrite(ledPin, HIGH);   // sets the LED on
  delay(1000);                  // waits for a second
  digitalWrite(ledPin, LOW);    // sets the LED off
  delay(1000);                  // waits for a second
}

Analogue in via Potentiometer


/*
 * AnalogInput
 * by DojoDave 
 *
 * Turns on and off a light emitting diode(LED) connected to digital  
 * pin 13. The amount of time the LED will be on and off depends on
 * the value obtained by analogRead(). In the easiest case we connect
 * a potentiometer to analog pin 2.
 *
 * http://www.arduino.cc/en/Tutorial/AnalogInput
 */

int potPin = 2;    // select the input pin for the potentiometer
int ledPin = 13;   // select the pin for the LED
int val = 0;       // variable to store the value coming from the sensor

void setup() {
  pinMode(ledPin, OUTPUT);  // declare the ledPin as an OUTPUT
}

void loop() {
  val = analogRead(potPin);    // read the value from the sensor
  digitalWrite(ledPin, HIGH);  // turn the ledPin on
  delay(val);                  // stop the program for some time
  digitalWrite(ledPin, LOW);   // turn the ledPin off
  delay(val);                  // stop the program for some time
}

This is a very straightforward "Hello World" task - but there's plenty to go wrong especially if you're nervous!

Here's the original version:
http://www.arduino.cc/en/Tutorial/AnalogInput

Analogue Input

Another Version:
http://www.arduino.cc/en/Tutorial/AnalogInput

Analogue in via LDR


/*
 * AnalogInput
 * by DojoDave 
 *
 * Turns on and off a light emitting diode(LED) connected to digital  
 * pin 13. The amount of time the LED will be on and off depends on
 * the value obtained by analogRead(). In the easiest case we connect
 * a potentiometer to analog pin 2.
 * Connect an LDR to ground and analog pin 2.
 *
 * based on:
 * http://www.arduino.cc/en/Tutorial/AnalogInput
 */

int potPin = 2;    // select the input pin for the potentiometer
int ledPin = 13;   // select the pin for the LED
int val = 0;       // variable to store the value coming from the sensor

void setup() {
  pinMode(ledPin, OUTPUT);  // declare the ledPin as an OUTPUT
}

void loop() {
  val = analogRead(potPin);    // read the value from the sensor
  val = (val*100);
  digitalWrite(ledPin, HIGH);  // turn the ledPin on
  delay(val);                  // stop the program for some time
  digitalWrite(ledPin, LOW);   // turn the ledPin off
  delay(val);                  // stop the program for some time
}

To Cover

Ramifications






The Task

  • Make sure you do the above. Not just once, but a number of times through the week. At least twice. You need to do it enough so that you feel reasonably comfortable and confident.

  • Clearly, I don't want you to submit your Arduinos. That means you need to submit some documentary evidence that you've completed your task. The most obvious way to do this is to submit some sort of video of your task working. If you can't do this, take photos. Bear in mind that you'll get extra marks for 'added value', so try to adapt and make more interesting your files. Simply repeating what we've already done will get minimal marks.

  • Zip or Stuff your patches, demos, photos, videos etc. into one file called your_student_number_"arduino01" (e.g. 0504335_arduino01.zip or 0504335_arduino01.sit), include a readme with your name and student number and, if necessary, how to use or just open the patch, and submit the whole thing here.

  • On Macintosh, zip or stuff your patches by selecting the relevant files and/or folders and right-clicking/control-clicking on them, choosing 'create archive'.

You might also be interested in:


The Projects

The projects and tasks are designed to help you through the various courses and materials that you'll have to deal with, and also to provide an active and practical element to what could otherwise become a rather dry and technical exercise. Tasks are small exercises - you may be asked to complete one or two per week. Projects are larger and carry a higher percentage of the mark. We will undertake two, three, four or more projects and tasks. The final project is usually an individual choice project, and will be worth significantly more than the others in terms of percentages in your portfolio. We will usually try to set aside a time to perform the projects in a public setting.