Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
BhavithiranSC LimAdrian
Published © MIT

EDU:BIT Pedestrian Crossing Traffic Light | MicroPython

Guide to program Pedestrian Crossing Traffic Light with EDU:BIT (project kit for micro:bit) using MicroPython

BeginnerFull instructions provided30 minutes903
EDU:BIT Pedestrian Crossing Traffic Light | MicroPython

Things used in this project

Hardware components

EDU:BIT
Cytron Technologies EDU:BIT
×1

Software apps and online services

Mu
Python Editor for micro:bit

Story

Read more

Code

Pedestrian Crossing Traffic Light

Python
This tutorial's full code
from edubit import *

display.show(Image.HAPPY)                            # show happy face on microbit display
while True:
	init()                                       # initialize EDU:BIT
	sets_servo_position(S1, position=0)          # close the pedestrian gate 
	sleep(500)
	set_led(Red, 0)                              
	set_led(Yellow, 0)                           
	set_led(Green, 1)                            # traffic light turns green
	sleep(2000)

	set_led(Red, 0)
	set_led(Yellow, 1)                           # traffic light turns yellow
	set_led(Green, 0)                            
	sleep(1000)

	set_led(Red, 1)                              # traffic light turns red
	set_led(Yellow, 0)
	set_led(Green, 0)
	sleep(500)
	sets_servo_position(S1, position=90)         # open the pedestrian gate
	sleep(2000)

Credits

Bhavithiran

Bhavithiran

16 projects • 7 followers
SC Lim

SC Lim

13 projects • 13 followers
Husband · Dad | Loves tinkering & making
Adrian

Adrian

1 project • 0 followers
Education is my passion, and making is my hobby.

Comments