AIR - Still Open

a workshop facilitated by Beatriz da Costa as part of Preemptive Media's AIR project
special thanks to In Wha Jeong for his assistance with the workshop preparation




CODE:

int val=0; // variable to hold potentiometer value
int potPin1 = 1; // Select the input pin for potentiometer (analog pin)

// digital pins:
int ledPin4 = 4; // Select the pin for data LED (green)
int ledPin5 = 5; // Select the pin for data LED (yellow)
int ledPin6 = 6; // Select the pin for data LED (red)

///////FUNCTION//////////
void writeLEDs() {
if (val > 10) {
digitalWrite(ledPin4, LOW); // Light up green LED on digital pin 4
}
else {
digitalWrite(ledPin4, HIGH);
}

if (val > 20) {
digitalWrite(ledPin5, LOW); // Light up yellow LED on digital pin 5
}
else {
digitalWrite(ledPin5, HIGH);
}

if (val > 30) {
digitalWrite(ledPin6, LOW); // Light up red LED on digital pin 6
}
else {
digitalWrite(ledPin6, HIGH);
}
}

//////////////////////////////
void setup() {
beginSerial(4800); // general serial baudrate, in this case used internally by arduino to send data to the PC (pin 1)
pinMode(ledPin4, OUTPUT); // Declare the ledPin as an OUTPUT
pinMode(ledPin5, OUTPUT); // Declare the ledPin as an OUTPUT
pinMode(ledPin6, OUTPUT); // Declare the ledPin as an OUTPUT
}

void loop() {
val = analogRead(potPin1); // read potentiometer value into variable
writeLEDs(); // Call writeLEDs function
delay (5); // delay for 5 milliseconds
}

SCHEMATIC:



EXPLANATION:

  • the 3 LEDS are used to indicate the value of the potentiometer:
    0-10: no LED lights up
    10-19: green LED lights up
    20-29: green + yellow LEDs light up
    30-max: green, yellow and red LEDs light up
  • in this set up, we are simulating the sensor values with the potentiometer. later the LEDs will indicate the pollution levels.