This is a scruffy page. Please do not imagine many of my pages are this incomplete.
Even in its present state, I hope it will amuse, be useful.
The purpose of this page is to present some challenges for programmers.
It assumes that the programmer at least has a small bar of LEDs... five, say? If he/ she has more, if they are arranged in a shape, so much the better. If they are "smart" LEDs, NeoPixels or similar, SO MUCH the better.
These can be accomplised, at some level, by people who know very little programming, have very limited hardware.
And good programs can be written which will produce the same results... but produce them well, rather than just "something that works". There's more to a good program than whether it works. But getting something that works, even if it isn't a good program, is worth something too... and, I hope, will be a fun journey, if nothing else.
These first level challenges are only about "pretty patterns", because they will be for people who ONLY have some LEDs attached to their computer.
One reader may have five LEDs in a straight line, capable of just one color. Fine! That will do for any of the following!
Others will have, say, 16 LEDs in a circle.
Some of the challenges will sound as if you "need" the circular layout. Not so! Just imagine in your mind that your strip of five is on a putty-like base, and that you can "stretch" it, and "bend" it around INTO a circle!
We'll call the LEDs LED0 ("LED zero"), LED1, LED2, LED3... and so on. If your LEDs are in a grid of columns and rows, of course other patterns become available... but for the purposes of these challenges, think of them being numbered....
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
By the way... once you know how to do subroutines, you REALLY ought, for many things, to have a subroutine along these lines: LedOnOff(x,y,state) (If you did LedOnOff(2,3,1), that would turn what ** I ** call LED17 ON. (Column (x coordinate) 2, Row named 3, "1" for "on"). Even in your program, in th deep internals, that would probably be LED17... for things like the pinMode statement.
(AND... I WILL stop digressing in a moment... you CAN buy ** 3D ** arrays of LEDs. (Short YouTube. Will open in new tab. Just close that to bet back here.) Very cool!
The first challenge: Write a program to, with short delays between each...
Turn LED0 on Turn LED0 off Turn LED1 on Turn LED1 off Turn LED2 on Turn LED2 off Turn LED3 on Turn LED3 off Turn LED4 on Turn LED4 off...
... and so on, until you get to your last LED. And then go back, start at the first one again, and carry on forever.
If your LED array is in a circle, that will give a single LED "on" at any one moment, rushing around the ring.
If your LEDs can be made to glow dimly or brightly....
1) Have the brightness weakest when LED0 is lit, and highest when the last LED is lit.
2) MUCH harder that you may imagine: Have THREE LEDs lit at any one time. The "front" one at one brightness, the next at medium brightness, the "trailing" LED quite faint. This will give a STRONG impression of something moving along the array, with a fading "trail".
If you LEDs can be made different colors....
Do the previous two again, but this time, have the color change, the higher the LED number.
More challenges for systems with JUST some LEDs....
Think about the various LED driven things you see all around you! Warning flashers, "gauges" (saying how loud something is, how full it is, etc, etc.)
Try to recreate them.
Turn on, all at once, LEDs 0, 2, 4, 6... Turn them off. Turn on, all at once, LEDs 1, 3, 5, 7... Turn them off.
... do that over and over.
(If you think of your OWN pattern, by all means go off and make that happen! These are just if you are "stuck" for "what could it do?")
Another attention getter:
In the following, each line is a moment in time
Each "-" is an LED that is off; each "*" is an LED that is on.
...*... ..***.. .*****. ******* ...*... ..***.. .*****. ******* ...*... ..***.. .*****. *******
... over and over! (I wrote the pattern out two times more than I needed to. It just seemed prettier that way!)
This page under development. There will be MORE ideas!
Even if your Arduino "only" has LEDs attached to it, as long as it is connected to the development PC, the serial monitor can be used for MUCH MORE than just displaying the results of "Serial.print..." statements. It can also be used to "send" "things you type on the keyboard" TO the Arduino!
See my page Sending data to Arduino from Serial Monitor for an explanation. Give it a try, if you think it half makes sense. (JerSp... that comment applies to you, too.)
If you can understand what that page tries to explain... or if you have other inputs connected to the LED array, you can use inputs to say "flash the pattern faster/ slower". Or maybe do a completely differnt pattern. If your LEDs can do multiple colors, you can tell the Arduino to change the colors being displayed. You might, for instance, set something up that could display "any" color, and you would adjust the current color with keys to say "More red/ less red", and other keys to say "More blue/ less blue". Etc.
How about making the LEDs be a "thermometer", or at least a gauge of some sort. (Either attach a sensor, or used the keyboard to say "show higher reading/ lower reading". With colors, you could introduce green for low numbers, yellow for middle numbers, red for high numbers. Would ALL the LEDs change? Or would the lower ones stay green, with a gband of yellow, then a band of red? How about when the number went above a certain level, the LEDs pulsed on and off, to make the "condition red" more noticable.
Page qWILL BE has been tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org. Mostly passes, just a few "No attribute" issues, arising from Google code.
....... P a g e . . . E n d s .....