The construction of these objects are following the same process for Project 1. The parallel construction for the wires and RGB LEDS is the simplest to me for creating this work and the way the lines follow the marks of the drift wood I find really meditative to create but really aesthetically pleasing. I after this project looking at the parts I would like to find really small LEDs and work on the drift wood Idea, I like the idea of doing really meticulous work and extending this idea further once I leave school.
The picture above shows the rang finder collecting data of the location of the person. There are 3 pins accessing the RGB functions of the LED and there are there are three outputs on the rang finder that are sending those outputs to the pins. ***CODE BELOW
long pulse, inches;
const int pwPin = 7;
const int redPin = 2;
const int bluePin = 3;
const int greenPin = 4;
int redVal, greenVal, blueVal;
void setup() {
//This opens up a serial connection to shoot the results back to the PC console
Serial.begin(9600);
}
void loop() {
pinMode(pwPin, INPUT);
pulse = pulseIn(pwPin, HIGH);
//147uS per inch
inches = pulse/147;
//redVal = map(inches, 5, 60, 0, 255);
//blueVal = map(inches, 5, 60, 255, 0);
//greenVal = map(inches, 5, 60, 100, 200);
if(inches < 10){
redVal = 0;
greenVal = 0;
blueVal = 255;
} else
if(inches < 30){
redVal = 0;
greenVal = 255;
blueVal = 0;
} else if (inches < 50) {
redVal = 255;
greenVal = 0;
blueVal = 0;
} else {
redVal = 0;
greenVal = 0;
blueVal = 0;
}
analogWrite(redPin, redVal);
analogWrite(bluePin, blueVal);
analogWrite(greenPin, greenVal);
Serial.print(inches);
Serial.print("in, ");
Serial.println();
Serial.println(redVal);
Serial.println(greenVal);
Serial.println(blueVal);
delay(500);
}
No comments:
Post a Comment