V205
Published © GPL3+

PSoC MicroPython Traffic Light!

A Traffic light program on the CY8CPROTO with micropython

IntermediateFull instructions provided1 hour238
PSoC MicroPython Traffic Light!

Things used in this project

Hardware components

CY8CPROTO-062-4343W
Infineon CY8CPROTO-062-4343W
×1
5 mm LED: Yellow
5 mm LED: Yellow
×1
5 mm LED: Red
5 mm LED: Red
×1
5 mm LED: Green
5 mm LED: Green
×1
Resistor 330 ohm
Resistor 330 ohm
A current limiting resistor for the LED. Other values(eg. 220,1k) may also work. Make sure that the resistor value is high enough.
×3
Jumper wires (generic)
Jumper wires (generic)
For connecting stuff together.
×2
Breadboard (generic)
Breadboard (generic)
×1
Computer, MacOS, Windows, or Linux
It will be easier to do this on Linux or Mac
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
Or similar.
×1

Software apps and online services

MicroPython
MicroPython
Install micropython on the board at:
Thonny IDE
Arduino MicroPython Lab

Story

Read more

Schematics

Schematic

This is the schematic for this project.

Code

Traffic light code

Python
This is the MicroPython code for this project.
Make sure that you have uploaded the micropython .hex file to the board.
import time
from machine import Pin





redLED = Pin('P9_0')                    # create pin object for pin P9_0. This is for the Red LED
redLED.init(Pin.OUT, Pin.PULL_DOWN)      # set pin as output and enable pull-down resistor.
redLED.low()                             # set value low.

yellowLED = Pin('P9_5')                    # create pin object for pin P9_5. This is for the yellow LED.
yellowLED.init(Pin.OUT, Pin.PULL_DOWN)      # set pin as output and enable pull-down resistor.
yellowLED.low()        

greenLED = Pin('P6_5')                    # create pin object for pin P6_5. This is for the green LED.
greenLED.init(Pin.OUT, Pin.PULL_DOWN)      # set pin as output and enable pull-down resistor.
greenLED.low()                             # set value low.
print("Start program")
while True: # repeat forever.
  
    redLED.low() # Turn off red for green light
    yellowLED.low()  # turn off yellow      
    greenLED.high() # turn on green
    print("Green Light!")
    time.sleep(5) # wait 5 seconds
  
    redLED.low() # turn off red light for yellow light
    yellowLED.high()   # turn yellow light on     
    greenLED.low() #turn green light off.
    print("Yellow Light")
    time.sleep(2) # wait 2 seconds

    redLED.high() # turn on Red light
    yellowLED.low()   # turn off yellow light     
    greenLED.low() # turn off green lignt
    print("Red Light")
    time.sleep(5) # wait 5 seconds
  
    
    
    

PSoC Traffic Light Github

This is the project’s code.

Credits

V205

V205

4 projects • 7 followers
V205 is a maker driven by ideas.

Comments