The Schematic
The Code
[sourcecode language="java"]
// p is our potentiometer
// r, g, & b our led's
int r=10,g=11,b=12,p=1,pval=0;
void setup(){
Serial.begin(9600);
pinMode(r,1);
pinMode(g,1);
pinMode(b,1);
}
void loop(){
// read the potentiometer
pval=analogRead(p);
// pass the value to cycle function
cycle(pval);
}
void cycle(int interval){
// map the pot value to something
// more managable
interval=map(interval,1,1023,30,300);
// write to serial for debugging
Serial.println(interval);
// flash values to rgb pins
flashPin(r,interval);
flashPin(g,interval);
flashPin(b,interval);
}
void flashPin(int pin,int interval){
// turn led on
digitalWrite(pin,1);
// read interval val from pot
delay(interval);
// turn led off
digitalWrite(pin,0);
delay(interval);
}
[/sourcecode]
The Implementation
http://youtu.be/YZBKMzh6Bg4
Haha. Very cool! I need to pick up a kit already. I dont know why I have'nt jumped on this wagon yet.
ReplyDeleteI highly recommend it. The open source hardware community is growing fast, so it's pretty easy to get into if you have the interest in learning electronics and it's just plain fun tinkering with this stuff.
ReplyDeleteWhat kind of kit would you recommend for beginners?
ReplyDeletethe Uno model has a lot of tutorials out there, so if you're comfortable with code but not too familiar with hardware, thats a good starting point
ReplyDeleteWord. Thanks for the tip! I'll be following your blog. Interesting content, keep it up!
ReplyDeleteThanks, I'll keep posting tutorials as I learn myself. Just ordered a bar LED graph and an 8x8 LED matrix so stick around for some more tutorials on them [:
ReplyDelete[...] The Schematic The Code The Implementation http://youtu.be/YZBKMzh6Bg4 [...]
ReplyDelete