Thursday, September 25, 2008



Today we improved on yesterday's code. The program now is better suited to the sensor we have with us and is now much more responsive and is also comparatively less jittery. The sensor didn't have anything written on it so finding a data sheet was difficult. The most similar component on the internet has a weak data sheet that we have displayed below. Eventually we got our values with a multimeter.

This apart, our circuit diagram from yesterday was inaccurate with its representation of the light sensor. We have remade it since then.

Today, we also tried our hand at prototyping the Light Vine Concept. This is in theory simpler but we haven't cracked the mechanics of the lemon battery yet. Our documentation is available in the above slideshow.

Our code today;


#define NUMREADINGS 10

int readings[NUMREADINGS];
int potPin = 0;
int ledPin = 9;
int val = 0;
int index = 0;
int total = 0;
int average = 0;
int ledOut = 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);
if (average >=260 ){
analogWrite(ledPin,0);
}else{
ledOut = abs(average - 255);
analogWrite(ledPin, ledOut);
delay(10);
}
}

Posted by Posted by Arjun Gehlot at 3:39 AM
Categories: Labels: ,

 

0 comments:

 
>