Final Project 3 – Implementation

All I need

  • Two paintings in A3 size (It could be better if it could be bigger, but A3 is already the biggest size I can get.)
  • One wooden board (attaching the painting on it)
  • One Arduino (with several wires and at least 3 red LEDs, 3 yellow LEDs and 2 blue LEDs)
  • One soldering machine (for making LEDs with longer wires)
  • One tape
  • One ultrasonic sensor(VM125, as shown in the following picture)
  • One power supply which offers 12V to the sensor (as shown in the following picture)

Draw the circuit diagram

diagram

There’re 6 groups of LEDs(A-F), which are connected to pin 13, 12, 11, 10, 9, 8 respectively. Use 220-ohm resistor connecting each group of LED to pin.

Build up the circuit

IMG_2321

Read the data sheet of the sensor. Sensor connection should be: (From right to left those four wires)

  • Connect the brown wire to the minus of the power supply(12V)
  • Connect the red wire to the plus of the power supply(12V)
  • Connect the orange wire the pin GND on Arduino
  • Connect the yellow wire to Analog pin A0 on Arduino

Create code

int sensorPin = A0; // select the input pin for the potentiometer
int sensorValue = 0; // variable to store the value coming from the sensor
float ratio = 0.01;
int counter;
bool on13,on9;

void setup() {
// put your setup code here, to run once:
// declare the ledPin as an OUTPUT:
pinMode(13, OUTPUT);
pinMode(12,OUTPUT);
pinMode(11, OUTPUT);
pinMode(10,OUTPUT);
pinMode(9,OUTPUT);
pinMode(8,OUTPUT);
Serial.begin(115200);

}

void loop() {

int temp = analogRead(0);
sensorValue = temp * ratio + sensorValue * (1 – ratio);

// No people detected
if (sensorValue > 831) {
digitalWrite(13,LOW);
digitalWrite(12,LOW);
digitalWrite(11,LOW);
digitalWrite(10,LOW);
digitalWrite(9,LOW);
digitalWrite(8,LOW);
on13=false;
on9=false;
}

// People far away detected
else if (sensorValue > 400 && on13==false) {
// LEDs on left
digitalWrite(9,LOW);
digitalWrite(8,LOW);
on9=false;
for(int i=50;i<=255;i++){
analogWrite(13,i);
delay(8);
}
on13=true;

for(int i=50;i<=255;i++){
analogWrite(12,i);
delay(8);
}

for(int i=50;i<=255;i++){
analogWrite(11,i);
delay(8);
}

for(int i=50;i<=255;i++){
analogWrite(10,i);
delay(8);
}
}

// People close detected
else if(sensorValue <= 400 && on9==false) {
// LEDs on right
digitalWrite(13,LOW);
digitalWrite(12,LOW);
digitalWrite(11,LOW);
digitalWrite(10,LOW);

on13=false;
for(int i=50;i<=255;i++){
analogWrite(9,i);
delay(8);
}
on9=true;
delay(700);

for(int i=50;i<=255;i++){
analogWrite(8,i);
delay(8);
}
}
}

  • The data from the sensor is super jerky, so I average the data using the formula « sensorValue = temp * ratio + sensorValue * (1 – ratio) ». However, it’s still not stable, but this sensor is already the best one after I tried out all other sensors we have in the Fablab. If possible, it would be better to buy another better sensor.
  • Print out the « sensorValue ». Choose the appropriate threshold for each distance judgement statement.
  • Using analogWrite() function instead of digitalWrite() function makes LED light up gradually rather than suddenly. analogWrite(pin, value), value from 0(always off) to 255(always on).
  • Add « &&on13==false » and « &&on9==false » to the distance judgement statement to decrease the operation times of delay() function.

 

Make LEDs with longer wires

Once the basic circuit and program run well, we can start creating the real installation. First we need to create LEDs with longer wires so that we can put the circuit underneath the painting.

 

Attach the first painting on the board

Change LEDs without wires into those new-made LEDs with longer wires

Attach LEDs and wires at the right position on the painting

IMG_2342

Write down « Hi » at the right position on the back of the second painting and attach the second painting on the top of the first painting

Test and adjust details

Final effect

It’s better to put a video here but I don’t know why I can’t add a video. I’ll play a background music « Like Sunday, Like Rain » on the exhibition day.

 

Publicités
Publié dans Uncategorized
Web2PDF