Last summer I created some resources to use with Micro:bit/s for CPC and over the next few months and I will try and share the best bits with the kind permission of CPC.
This first one uses Micropython and a neopixel. The neopixel is from this kit:
The picture below shows how the Micro:bit is set up:
The script shows 3 pictures on the led screen of happy, angry and meh(in between). Whilst doing this it also instructs the neo-pixel to light up red if angry, yellow if meh or green if happy. Why not have a go yourself.
Here is the code:
from microbit import *
import neopixel
np = neopixel.NeoPixel(pin0,1)
def Angry():
np[0] = (255,0,0)#Red
np.show()
display.show(Image.ANGRY)
sleep(3000)
np.clear()
def Happy():
np[0] = (0,255,0)#Green
np.show()
display.show(Image.HAPPY)
sleep(3000)
np.clear()
def Meh():
np[0] = (255,69,0)#Yellow
np.show()
display.show(Image.MEH)
sleep(3000)
np.clear()
while True:
Happy()
Angry()
Meh()
No comments:
Post a Comment