I have a row of 10 LED's.
A slowly building wind would light them in sequence from left to right until all 10 would be lit.
Here is an image of my setup with Wind Sensor, LED's and Arduino:
[img=400x400]http://mydata.salve.edu/emersonb/post/led_wind.jpg[/img]
Here is the code I was trying to get to work with no luck.
Code: Select all
// Controlling LED's using a wind sensor (variable resistor?)
byte ledPin[] = {4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; //pins used for LED's
int windSen = 2; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
void setup()
{
// set all pins to output
for (int x = 0; x < 10; x++) {
pinMode (ledPin[x], OUTPUT); }
}
void loop()
{
val = analogRead(windSen); // reads the value of the wind sensor (value between ? and ?)
for (int i = 0; i < 100; i++) {
if( val < 5) { digitalWrite(ledPin[0], HIGH);}
else
{ digitalWrite(ledPin[0], LOW);}
if( (i * 10) > val) { digitalWrite(ledPin[i], HIGH);}
else
{ digitalWrite(ledPin[i], LOW);}
}
} Thanks,
emersonb-