This weekend Barry and I found ourselves in a Dollar Tree store– one of the greatest places known to man.
We picked ourselves up some toys to play with, all for a dollar:
The code we used can be found down below. Basically it reads from a button, which changes the state between off and glowing each LED in sequence. The circuit is similarly simple, the diagram also can be found below.
Continue for code and schematic…
Here’s the code:
//Code for Mr. Blinkie, AKA the psychedelic beaglepede //July 17 2010 //Written by Hadley Piper int state = 0; // we declare these here so they can be accessed globally, int button = 0; // meaning in different functions. void wave(){ // this is the function that controlls the light int i; int j; // counter variables //we put the LED's sequentially in pins 5-9 for looping convenience for (i = 5; i< 10; i++){ // i counts the LED pin if (digitalRead(button) == HIGH){ //check for button press state = 0; break; } if (state == 0) break; //check if button was pressed during inner loop for (j = 0; j<=50050; j+=350){ //loop to fade each LED on analogWrite(i,j); //set pin i to pwm duty cycle j delay(1); //small aesthetic delay if (digitalRead(button) == HIGH){ //another check for button press state = 0; break; } } delay(100); //let the light stay on for a bit for (j = 50050; j>=0; j-=350){ //loop to fade each LED off analogWrite(i,j); //set pin i to pwm duty cycle j delay(1); //small aesthetic delay, again if (digitalRead(button) == HIGH){ //last check for button press state = 0; break; } } delay(100); //third aesthetic delay } } void setup(){ pinMode(5, PWM); //set the LED pins to PWM pinMode(6, PWM); pinMode(7, PWM); pinMode(8, PWM); pinMode(9, PWM); pinMode(button, INPUT); //set button pin to input } void loop(){ if (state == 0 ){ //turn all LED's off in resting state analogWrite(5, 000); analogWrite(6, 000); analogWrite(7, 000); analogWrite(8, 000); analogWrite(9, 000); if (digitalRead(button) == HIGH){ //check to see if button was pressed state = 1; delay(500); SerialUSB.println("I am the Great BEAGLEPEDE!!"); //a sign of things to come } } if (state == 1){ //if the button is in state 1, call the wave function wave(); if (digitalRead(button) == HIGH){ //check for button press and reset to state 0 state = 0; delay(500); } } }
And here’s the schematic:
I’m excited to have the beaglepede around because I think he’s going to be a cool visualizer…there’s lots of things you can do with a row of LEDs!




on July 19, 2010 at 1:02 am
Permalink
Cute…but don’t you think a 72MHz ARM is a bit overkill to read a button and flash some LEDs
on July 19, 2010 at 1:38 am
Permalink
It’s a cool. may be use small form factor board based on Atom Intel and more complex algoritm for leds ?
on July 19, 2010 at 2:05 am
Permalink
To David, yeah totally, but that’s all I had!
I’m going to get a small mic and make a spectrum analyzer [partitioning the space into the 5 LEDs], and then make some more interesting patterns from there. Actually there are about a million things I want the beaglepede to signal, but that’s where I’m starting. =]