We chose to work with a light sensor and two breadboard hooked it up in a way that LED's on one would give light when the sensor was in darkness. Check the above video for more.
This was to prototype one leaf for our "Moonflower" concept.
There was some jitter produced by the light sensor and we did try to smoothen it out by taking snippets from the "Smoothing" program. Though this smoothens the code being printed to the computer we failed to make it smooth the code to the LED's.
Our current schematics and code can be found below;
#define NUMREADINGS 10int readings[NUMREADINGS];
int potPin = 0;
int ledPin = 9;
int val = 0;
int index = 0;
int total = 0;
int average = 0;
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
for (int i = 0; i <>
readings[i] = 0;
}
void loop() {
total -= readings[index];
readings[index] = analogRead(potPin);
total += readings[index];
index = (index + 1);
if (index >= NUMREADINGS)
index = 0;
average = total / NUMREADINGS;
Serial.println(average);
val = analogRead(potPin);
val = val/4;
Serial.print(val);
Serial.println("");
analogWrite(ledPin, val);
}
0 comments:
Post a Comment