Arduino Coding II

Week 3 Review

Arduino is the name of the Software Programming component and the Physical computer board (hardware). We can write our own programs using built in functions and loops, or we can create our own functions.

We programmed the lilypad (hardware) to blink its light, then changed the speed using a light sensor to control it. Doing this we introduced a number of physical computing concepts were also introduced such as differences between Analogue and Digital, Sensor and Actuator, Input and Output.

In addition there were programming concepts introduced such as variables, loops, functions, and libraries. There were a number of functions such as analogWrite, analogRead, digitalWrite, digitalRead, map, Serial.begin, Serial.println. A full list of functions can be found at

Week 4 - Designing Interactions

This week we learnt that when designing an interaction we have to:
1). Continuously communicate what is happening with the system (STATUS);
2). Communicate what choices are available and how they might be accessed (CHOICES);
3). Create and Communicate "Channels" through which those choices can be made (SENSORS);
4). Communicate how these changes will affect the system going forward (RESULTS);
5). Communicate the results of the changes to the system (NEW STATUS);

We saw that this set of steps happens all the time in our everyday interactions such as moving a mouse (3. & 1.) seeing the pointer move on screen (1. & 5.), when the pointer goes over a URL, it changes to a pointing finger and hand (2. & 4.), and once clicked the page changes, or at the very least the browser lets you know that the page is loading (5. & 4.).

As you can see these all happen very quickly. We are so used to them now that we don't notice them most of the time, however each had to be designed in order to make them disappear.

Week 4 Exercises

This week each group was assigned a Sensor (INPUT) and Actuator (OUTPUT). The groups then proceeded to enable one part, then enable the other part, then attempt to coax out the differences to have the sensor affect the actuator.

The Sensors:

Accelerometer (Triple axis - three sensors in one)
Force Sensor (FSR - Force Sensitive Resistor)
Light Sensor (aka LDR - Light Dependant Resistor)
Temperature sensor
Button (digital - only two states either ON or OFF)
Switch (digital)

The Actuators:

Vibration motor (aka Vibe Board)
Bright White LED
Tricolour LED (Red, Green and Blue - three actuators in one)
Buzzer (piezo Electric - Vibrating metal makes a sound)

Triple Accelerometer to Triple LED Program

Read the accelerometer and output the brightness to and RGB LED.


these constants describe the pins. They won't change:
const int xPin = 3; x-axis of the accelerometer
const int yPin = 2; y-axis
const int zPin = 1; z-axis (only on 3-axis models)

const int rPin = 9;
const int gPin = 10;
const int bPin = 11;

int xValue = 0;
int yValue = 0;
int zValue = 0;

void setup()
initialize the serial communications:
pinMode(rPin, OUTPUT);
pinMode(gPin, OUTPUT);
pinMode(bPin, OUTPUT);

void loop()
Read the sensors
xValue = analogRead(xPin);
yValue = analogRead(yPin);
zValue = analogRead(zPin);

Send out the values to the RGB LED
digitalWrite(rPin, xValue);
digitalWrite(gPin, yValue);
digitalWrite(bPin, zValue);

print the sensor values:
print a tab between values:
delay before next reading: