In a previous post, I got a GlowBug to work with a micro:bit (http://robotsandphysicalcomputing.blogspot.co.uk/2016/08/microbit-and-glowbug.html) . In this post, I will show a relatively simple traffic lights system produced by turning off and on the pixels via a micro:bit.
Code
from microbit import *
import neopixel
# Setup the Neopixel strip on pin0 with a length of 3 pixels
np = neopixel.NeoPixel(pin0, 3)
while True:
#red
np[0] = (255, 0, 0)
np[1] = (0,0, 0)
np[2] = (0,0,0)
np.show()
sleep(1000)
#red and orange
np[0] = (255, 0, 0)
np[1] = (255, 69, 0)
np[2] = (0,0,0)
np.show()
sleep(1000)
#green only
np[0] = (0, 0, 0)
np[1] = (0, 0, 0)
np[2] = (0,255,0)
np.show()
sleep(1000)
#orange
np[0] = (0, 0, 0)
np[1] = (255, 69, 0)
np[2] = (0,0,0)
np.show()
sleep(1000)
It is simple, timings and more lights can be added to make a more interesting system. If you have done something similar please use the comments to discuss or link to it.
Thank you to @SCC_Lancaster for the loan of a micro:bit.
Related Posts
Microbit and GlowBugs
CodeBug and Glowbugs
All opinions in this blog are the Author's and should not in any way be seen as reflecting the views of any organisation the Author has any association with.
Robots and getting computers to work with the physical world is fun; this blog looks at my own personal experimenting and building in this area.
Subscribe to:
Post Comments (Atom)
Detecting and logging magnetism with a microbit
Producing a data logger using the microbit to detect and log changes in the magnetic field. Traces The micro:bit includes a built-in compas...
-
In the previous blog posts for this 'series' "It is a good time...." Post 1 looked at the hardware unpinning some of...
-
The Raspberry Pi Foundation recently released a programming activity Alien Language , with support Dale from Machine Learning for Kids , tha...
-
You don't need to buy a robot to get programming a robot, now there are a range of free and relatively simple to start with robot simula...
No comments:
Post a Comment