Sunday, 8 May 2016

2: Multi-Blink

Large arrays of LEDs are often used to create massive outdoor signs and animations because they’re both bright and efficient. While we don’t have the millions of LED pixels that a display in Times Square might have, we can still create some fun patterns.

Background Information

In this experiment we explore the subject of pins. Each LED (as well as the other inputs and outputs) is connected to a specific pin on the microcontroller.
Pins are all uniquely numbered, and each input or output component on the Arduino is labeled with the pin number it’s connected to – that’s the (Digital) 1, 23(Analog) A1, etc. lettering next to each pin.
Every pin can be separately controlled; for instance pin 4 can be set HIGH at the same time pin 5 is set LOW. Some pins (as we’ll later discover) have special powers, but every pin is at least able to accomplish digital input and output.
We started with a single LED, but we can add our own:

Code Components

Whoa! Block explosion! This experiment calls for a lot of blocks:

Instead of introducing a new block, we’ll be adjusting the value of Set Digital Pin’s top pin - the pin number. This value specifies which of the Sandbox’s pins we’ll be toggling.

Do This

In our unfinished example, the blocks are all arranged in groups of four. Each group begins by setting a pin HIGH, then delays for a second and sets it back to LOW. Notice that each group toggles a different pin, ranging from pin 9 to pin 11. Stack the groups-of-four on top of each other in the loop, then upload and enjoy the exciting animation.
If the LED change is too slow for you, try adjusting the delays to make it faster, or perhaps you want to change the pins to adjust the order of the blinks.

Further Explorations

  • Try adding more blocks to create slicker patterns. 
  • Try turning on more than one LED at a time. Turn them all on (and shield your eyes)!




No comments:

Post a Comment