Hi,
I have very little experience with this type of stuff and was wondering if anyone could help me with a project I'm working on. I'm trying to make a light system for my apartment by using the Shifty VU shield on the Arduino duemilanove board to control relays that switch incandescent lights on and off.
I've got the two boards and have been trying to figure out how to use the inputs from the Shifty VU board. I've written a simple program to try to narrow down the range of the inputs by watching the LED pin 13 blink on and off, but it seems that the inputs don't really change their value. It seems to always be between 321 and 384
I'm pretty sure there's nothing wrong with the code and was wondering if anyone had any sort of advice for using the inputs from the Shifty VU board.
int sensorPin = 2;
int ledPin = 13;
int sensorValue = 0;
bool flag = true;
long previousMillis = 0;
long interval = 10000;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop () {
for(;;) {
if(millis()-previousMillis > interval){
sensorValue = analogRead(sensorPin);
previousMillis= millis();
digitalWrite(ledPin, LOW);
delay(500);
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
if(sensorValue >= 256 and sensorValue < 320) {
digitalWrite (ledPin, LOW);
delay(2000);
digitalWrite (ledPin, LOW);
delay(2000);
digitalWrite (ledPin, LOW);
}
if(sensorValue >= 321 and sensorValue < 384 ) {
digitalWrite (ledPin, LOW);
delay(2000);
digitalWrite (ledPin, HIGH);
delay(2000);
digitalWrite (ledPin, LOW);
}
if(sensorValue >= 385 and sensorValue < 448 ) {
digitalWrite (ledPin, HIGH);
delay(2000);
digitalWrite (ledPin, LOW);
delay(2000);
digitalWrite (ledPin, LOW);
}
if(sensorValue >= 449 ) {
digitalWrite (ledPin, HIGH);
delay(2000);
digitalWrite (ledPin, HIGH);
delay(2000);
digitalWrite (ledPin, LOW);
}
}
}
}