This is one of the first sketches I implemented for the Blinkenlight Shield. In some sense this sketch is the reason why I invented the shield at all. Actually I was planning a 100+ LED version but then considered the complex setup with shift registers and the like. Then I decided that I would go for a quick prototype with whatever I find in my junk box and 20 LEDs have to suffice for that.
So here it is. The first small light show for the Blinkenlight Shield.
// // www.blinkenlight.net // // Copyright 2011 Udo Klein // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see http://www.gnu.org/licenses/ void setup() { for (uint8_t pin=0; pin<20; ++pin) { pinMode(pin, OUTPUT); } } void blink(const uint8_t pos) { digitalWrite(pos, HIGH); delay((sqrt(((float)20 - pos)/20) - sqrt((19.0 - pos)/20)) * 500); digitalWrite(pos, LOW); } void loop() { for (uint8_t pos=0; pos<19; ++pos) { blink(pos); } for (uint8_t pos=19; pos>0; --pos) { blink(pos); } }
Basically it counts up and down and blinks at the position corresponding to the counter. In order to get a realistic bounce effect the on time of the LEDs is varied. The underlying formula is the well known h = g*t^2/2. Since the program varies h, we have to solve for t: t = sqrt(2*h/g) = sqrt(h)*sqrt(2/g). The important part is that this is a square root function. The constants are not really important. I did not compute them but experimented a little bit to make the result „look natural“.
As the video shows we get a nice bouncing effect for almost no implementation effort. If you like it you might also like the Knight Rider effect.
This is a better rendition of how my pasted sketch looks like. note in particular “pin<20” which change to “pin>20” when I send it. Very odd.
You copied the markup instead of the sketch. Hover the mouse in the upper right corner to get the plain text file. This should do it.
Hi, this will sound very dumb to an experienced user, but having just received my Arduino and Blinkenlight shield I don’t want to damage anything.
First, there are jumpers on the blinkenlight. Do I need to set any of these prior to use?
Second, do I simply mount the shield on the Arduino Uno, (when powered off) and then on power download your sketch?
Thanks
Congratulations and thank you for buying it. The shield was designed that you can not damage anything no matter how you put the jumpers. You can leave the shield on the Arduino during upload. For all experiments but the camera experiment you need to put the jumper to connect the middle pin to GND. Follow the link for a picture https://blinkenlightblog.files.wordpress.com/2011/10/00f_blinkenlight_final_board_back_red_shunt_10001.jpg
hallo zusammen, hier ein video des bouncing balls in der disco. 20 dioden eigebohrt in eine pvc doppelstegplatte. das ganze verdrahtet und mit dem blinkenlighty verbunden (pfostenstecker).