Go Down

Topic: Arduino with Shifty Vu (Read 1 time) previous topic - next topic

F-15C

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.


Code: [Select]

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);
       }
       
    }
  }
}

PaulS

Oh, this is good:
Code: [Select]
void loop () {

   for(;;) {

An infinite loop as the only content of a function called in an infinite loop.

Do you have a link to the Shify VU thing?

What is connected to the sensor pin? Something on the Shifty VU shield?

What is the purpose of previousMillis and interval? Doesn't look like they are doing a whole lot.

Why are you storing the unsigned long returned by millis in a signed long? Do you favor data loss for some reason?

Do you know how to use Serial.print for debugging purposes? You could print the value, and see it in the Serial Monitor window, instead of guessing it's value by flashing an LED on and off.

More questions that answers, I'm afraid.

F-15C

Like I said, I'm kinda new to programming,

Here's a link to the Shifty Vu
http://docs.macetech.com/doku.php/shifty_vu_shield

The Shifty Vu puts an output into sensor pin 2 and 3.

I'm not sure what data loss is, but I originally used the millis to as an interval for when the chip would read the input from sensor pin 2. I got kinda lazy and started using the delay function after a while.

I didn't know about the serial.print. I'll give that a try.


F-15C

#3
Aug 15, 2010, 03:15 am Last Edit: Aug 15, 2010, 03:16 am by F-15C Reason: 1
I've got the Serial.print working, although now, when there is no music going into the Shifty Vu, the values on analog pin 2 and 3 are around 200 to 300, but when the music is turned on, the values drop to zero. I'm not sure why.

Code: [Select]
int sensorPinA = 2;
int sensorPinB = 3;
int sensorValueA = 1;
int sensorValueB = 1;


void setup() {
 Serial.begin(9600);    
}

void loop() {  
 
     for(;;) {
     
         
           sensorValueA = analogRead(sensorPinA);
           sensorValueB = analogRead(sensorPinB);
       
           
     Serial.print("Value");      
     Serial.print("\t");              
   
     Serial.print("A 2");
     Serial.print("\t");
     Serial.print(sensorValueA);
     Serial.print("\t");
     
     Serial.print("B 3");
     Serial.print("\t");
     Serial.print(sensorValueB);
     Serial.print("\t");
       delay(200);            
     
     Serial.println("");      
   }
}

macegr

The documentation page is at: http://docs.macetech.com/doku.php/shifty_vu_shield

The used pins are listed in the table next to the black and white graphic of the shield.

One of the posts in this forum containing the circuit is here: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1238824988
Unique RGB LED Modules and Arduino shields: http://www.macetech.com/store

macegr

Same here...

F-15C, please contact macetech directly to figure out what's happening, it might be a hardware issue that we can fix.
Unique RGB LED Modules and Arduino shields: http://www.macetech.com/store

Go Up