LDR Circuit Intro to IMA Homework #2

For this assignment, I made a circuit that turns the LEDs off gradually when light intensity exceeds a certain bound (where the boundary is particular for each LED). I gave the LEDs different responses for different sensorValues and parameters. I used ‘if,’ ‘else if’ statements, ((sensorValue > x ) && (sensorValue < x )), and (sensorValue > x ) to create these parameters. For instance, for the green LED, when the sensor value is between 1-300 (as can be viewed in the serial monitor, which is set up in the code using Serial.print), the green LED is set to HIGH; when it exceeds 300, it is set to LOW.

See below schematic, images, demonstration video, and code (which contains additional information) for further details.

The below images show the LEDs gradually lighting up as the light source moves away from the LDR:

 

Watch it in Action \/ \/

 

Demonstration Video

 

CODE:

//label each of the pins according to the colour of their LED

int red = 3;
int blue = 2;
int yellow = 4;
int green = 5;

int sensorValue = 0; // value read from the LDR, initially set to 0
int outputValue = 0; //initial output value set to 0

void setup() {

Serial.begin(9600); //sets the baud rate to 9600 to coincide with that selected in the serial monitor

//define the LEDs as outputs

pinMode(red, OUTPUT);
pinMode(blue, OUTPUT);
pinMode(green, OUTPUT);
pinMode(yellow, OUTPUT);
}

void loop() {

int sensorValue = analogRead(A0); // read the value from the sensor
Serial.println(sensorValue); //prints the values coming from the sensor on the screen
delay(1);

// print the results to the Serial Monitor:
Serial.print(“sensor = “);
Serial.print(sensorValue);
Serial.print(“\t output = “);
Serial.println(outputValue);
delay(1);

{

if ((sensorValue > 1) && (sensorValue < 300)) { //create parameters of sensor value (in this case with the LDR, the sensor value is the light intensity)
digitalWrite (green, HIGH);
}
else {                                         //if the sensor value is above 300, turn the LED off
digitalWrite (green, LOW);
}
}

{
if ((sensorValue > 300) && (sensorValue < 500)) {
digitalWrite (blue, HIGH);
}
else {
digitalWrite (blue, LOW);
}
}

{

if ((sensorValue > 600) && (sensorValue < 800)) {
digitalWrite (red, HIGH);
}
else {
digitalWrite (red, LOW);
}
}

{

if (sensorValue > 900) {
digitalWrite (yellow, LOW);
}
else {
digitalWrite (yellow, HIGH);
}
}
}

Intro to IMA week one — Rain Room and Dorothy’s Ruby Slippers

‘Rain Room,’ is an interactive installation that allows visitors to experience the sensation of being caught in the rain without actually getting wet.

In The Wizard of Oz, our heroine Dorothy acquires a pair of magical ruby slippers that, when she taps her heels together three times, transport her back home.

Although I would love to magically transport the slipper wearers across space, the slippers I intend to make will simply light up when the wearer taps their heels together. I will use copper tape on each heel that will be connected to wires that run up the backs of the legs and connect to the arduino strapped to the lower back.

Dorothy slippers — trial video demonstration