Get your own customer support community
 

Rotarty switch to change scripts

Hey again all!

So i got the whol scripting thing going thanks to your help.
All BlinkM's are powered from an external 5v adapter

But for my purposes what if like to do is store say 13 scripts in 1 sketch and upload it to ardunio. Then connect all 13 digital points to a rotary dial , and from that to a single push button switch.

So you rotate the dial to the script you want thats already on Ardunio, then hit the push button and it sends it down the i2c chain to all 8 BlinkM's

Has anyone done this before!?

I've tried using the base arduino code from here http://arduino.cc/en/Tutorial/Button and modifying the code, but it didnt work to well.... it just seemed to make it go red.

Here is the best part of my code

void setup()
{

// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);

BlinkM_beginWithPower();
BlinkM_stopScript(all_call); // turn off startup script
BlinkM_setRGB( all_call, 0x00,0x00,0x00);
}

void loop()
{

// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
BlinkM_setRGB( all_call, 0x00,0xff,0x00);
delay(500);
BlinkM_setRGB( all_call, 0x00,0x00,0xff);
delay(500);
} else {
BlinkM_setRGB( all_call, 0xff,0x00,0x00);
}
}

Thanks in advance all!
 
happy I’m hopefull
Inappropriate?
1 person has this question

User_default_medium