Skip to content

Use a simple programming language to turn LED lights on and off.

Notifications You must be signed in to change notification settings

ourschar/blinking

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blinking LEDs

Use a simple programming language to turn LED lights on and off.

LED lights can be turned off and on according to the 8-bit representation of a binary number stored in memory. For example, in a program that stores the value 2 in the variable 'a', and then calls the output command, the second from the right bulb will turn on. 2 = 0000010 which corresponds to turning on the second from the right bulb.

Likewise, a program that stores the value 3 in the variable 'x' and then calls the output command, will light up the two right-most bulbs. 3 = 0000011 which corresponds to turning on the two right-most bulbs.

Multiple calls to output will be shown with a delay of 1 second between them. This creates a nifty animation as the bulbs cycle through commands!

Demo

Try it out!

http://primaryobjects.github.io/blinking

Examples

Light Right-Most Bulb

ld a,1 |
out (0),a |

Output

......*

Light Second From Right Bulb

ld a,2 |
out (0),a |

Output

.....*.

Animated Bulbs

Multiple output commands will light bulbs with a 1 second delay between outputs, demonstrating a cool animation effect. Here is a simple example program with 4 output commands, with the last command turning all of the bulbs off.

ld a,1 |
out (0),a |
ld b,2 |
out (0),b |
ld c,4 |
out (0),c |
ld d,0 |
out (0),d |

Output

......*
.....*.
....*..
.......

Why

This is part of a programming challenge, posted on /r/dailyprogrammer

[2016-11-02] Challenge #290 [Intermediate] Blinking LEDs

Developed using Twitter Bootstrap and React.

Author

Kory Becker

http://primaryobjects.com

About

Use a simple programming language to turn LED lights on and off.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 63.7%
  • CSS 29.3%
  • HTML 7.0%