Chasing LEDs with the pyMCU

After thinking about what else I could use the pyMCU for, a “chasing” LED array seemed like an easy enough task.  It is very simple connection-wise.  It’s the same as the blinking light post, just add LEDs – and resistors preferably – to whatever pins you’re using.  As for the code, It took some thought on my part as to how to loop up and down instead of just starting over at pin 1 (see code after “read more”), but things turned out pretty well considering it was done with five green LEDs that I had on hand:

Yes, it’s one of the shortest videos I’ve posted, maybe the shortest, but there’s not really much more to it.  The really interesting thing about the pyMCU is that everyting code-wise lives on the computer.  This board isn’t necessarily meant for industrial use.  However, considering the cost, ($24.95) from pyMCU.com, this little board could be a throw-away item in that scenario.  I’d have a hard time substituting it for industrial-grade equipment, but maybe it could have some data-acquisition uses.

Anyway, here’s the Python code for this little LED-chasing loop:

########################################################

import pymcu           # Import the pymcu module

mb = pymcu.mcuModule() # Initialize mb (My Board) with mcuModule Class Object – Find first available pymcu hardware module.

for repeat in range(1,100):
for x in range(1,11):

if x <= 5:
y = x
else:
y = (11 – x)

mb.pinHigh(y)
mb.pausems(50)
mb.pinLow(y)

########################################################


I’m definitely no Python programming expert, and have been going through the Learn Python the Hard Way online lessons.  If you’re interested, be sure to check out my progress going through this book.  Also, if you’re wondering where to get LEDs, why not order a 80 pack of assorted LEDs with resistors from Amazon?  I just ordered a package, so I’m sure they’ll be involved in a project sooner or later.

  1. More fun with pyMCU over at JcoPro.net | pyMCU - pingback on October 11, 2012 at 11:36 pm
  2. Using the pyMCU with LEDs to create a simple light paintings - pingback on October 16, 2012 at 6:35 am

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackbacks and Pingbacks: