Things used in this project

Hardware components:
475267 240424 01 front zoom kankcmvqdh
Raspberry Pi Zero Wireless
×1
3 Colour 12V Traffic Light Tower
×1
Pimoroni Automation pHAT
×1
Software apps and online services:
SSH Client
Can be skipped if you access the pi directly with a screen and keyboard etc.
*Optional* Adapters and Cables
*Optional* Adapters and Cables to connect screen and keyboard to Pi, OR USE SSH
Hand tools and fabrication machines:
Thing for making holes.
09507 01
Soldering iron (generic)
Electrical Insulating Tape (PVC tape)

Code

demo code to test automation outputs 1-3 in an endless loopPython
Pimoroni Automation pHAT demo code
#!/usr/bin/env python

import automationhat
import time
import os
import sys

counter = -1
lightPattern = [
    [1,0,0],
    [0,1,0],
    [0,0,1],
    [0,1,1],
    [0,1,0],
    [1,1,0],
    [1,0,0],
    [1,1,0],
    [0,1,0],
    [0,1,1],
    [0,0,1],
    [0,0,0],
    [1,0,1],
    [0,1,0],
    [0,0,0],
]

def increment():
    global counter
    counter+=1
    if counter==len(lightPattern):
        counter = 0

def doCurrentCycle():
    currentCycle = lightPattern[counter]
    print currentCycle
    if (currentCycle[0]==1) :
        automationhat.output.one.on()
    else:
        automationhat.output.one.off()

    if (currentCycle[1] == 1):
        automationhat.output.two.on()
    else:
        automationhat.output.two.off()

    if (currentCycle[2] == 1):
        automationhat.output.three.on()
    else:
        automationhat.output.three.off()

    time.sleep(2)



while True:
    increment()
    doCurrentCycle()

Credits

0b65eef865f2306d79d2ecd0081e96c8
Tyeth
3 projects • 3 followers
Love solving problems
Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaBlog