From a8c4e899b76c6c217af5aa7714243fa826a8887a Mon Sep 17 00:00:00 2001 From: Ryan Walmsley Date: Mon, 6 Apr 2015 18:53:48 +0100 Subject: [PATCH 1/4] Added Traffic HAT --- src/en-GB/description/overlay/traffic-hat.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/en-GB/description/overlay/traffic-hat.md diff --git a/src/en-GB/description/overlay/traffic-hat.md b/src/en-GB/description/overlay/traffic-hat.md new file mode 100644 index 0000000..4a5522d --- /dev/null +++ b/src/en-GB/description/overlay/traffic-hat.md @@ -0,0 +1,7 @@ +#Traffic HAT + +###A quick and easy way to learn the basics of GPIO on a budget. All in a nice HAT. + +```python +Insert demo program here +``` From 8686a968b03d72bfd68adc01549e5bbc66f10b48 Mon Sep 17 00:00:00 2001 From: Ryan Walmsley Date: Mon, 6 Apr 2015 19:50:25 +0100 Subject: [PATCH 2/4] Added Traffic HAT --- src/en-GB/description/overlay/traffic-hat.md | 76 +++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) diff --git a/src/en-GB/description/overlay/traffic-hat.md b/src/en-GB/description/overlay/traffic-hat.md index 4a5522d..e4f2c27 100644 --- a/src/en-GB/description/overlay/traffic-hat.md +++ b/src/en-GB/description/overlay/traffic-hat.md @@ -3,5 +3,79 @@ ###A quick and easy way to learn the basics of GPIO on a budget. All in a nice HAT. ```python -Insert demo program here +import RPi.GPIO as IO +from time import sleep + + +IO.setmode(IO.BCM) + +IO.setup(22,IO.OUT) +IO.setup(23,IO.OUT) +IO.setup(24,IO.OUT) + +#Buzz +IO.setup(5,IO.OUT) + +IO.setup(25,IO.IN,pull_up_down=IO.PUD_UP) + +while True: + IO.output(22,1) # Turn the Green LED On / 1 + sleep(0.11) #S1 + print("Green ON") + if(IO.input(25) == 0): + print("BUTTON PRESS") + IO.output(22,0) # Turn the Green LED Off / 0 + print("Green Off") + IO.output(23,1) # Turn the Yellow LED On / 1 + print("Yellow ON") + print("Sleep") + sleep(2) # Wait for 1 Second + print("Sleeped") + + IO.output(23,0) # Turn the Yellow LED Off / 0 + print("Yellow Off") + IO.output(24,1) # Turn the Red LED On / 1 + print("Red ON") + + print("Sleep") + sleep(2) # Wait for 1 Second + print("Sleeped") + + i = 0 # Set A Counter Variable + + while (i<10): # The Repeat Loop + print("Buzz") + IO.output(5,1) # Turn the Yellow LED On / 1 + + sleep(0.1) # Wait for 0.1 Seconds + + IO.output(5,0) # Turn the Yellow LED Off / 0 + + sleep(0.1) # Wait for 0.1 Seconds + + i = i+1 #We add 1 to the counter to keep track of the loop + + # We want to blink the Yellow LED 3 Times + print("Count Begin") + sleep(0.5) + i = 0 + while (i<3): # The Repeat Loop + print("Blink") + IO.output(23,1) # Turn the Yellow LED On / 1 + + sleep(0.5) # Wait for 0.1 Seconds + + IO.output(23,0) # Turn the Yellow LED Off / 0 + + sleep(0.5) # Wait for 0.1 Seconds + + i = i+1 #We add 1 to the counter to keep track of the loop + + + print("Red Off") + IO.output(24,0) # Turn the Red LED Off / 0 + print("Green ON") + IO.output(22,1) # Turn the Green LED On / 1 + sleep(2) + ``` From bfd771ae6007f8cea5f25357890cec80566bc43a Mon Sep 17 00:00:00 2001 From: Ryan Walmsley Date: Mon, 6 Apr 2015 19:50:47 +0100 Subject: [PATCH 3/4] Added traffic hat --- src/en-GB/overlay/rtk-000-001 (copy).json~ | 36 ++++++++++++++++++++++ src/en-GB/overlay/traffic-hat.json | 36 ++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 src/en-GB/overlay/rtk-000-001 (copy).json~ create mode 100644 src/en-GB/overlay/traffic-hat.json diff --git a/src/en-GB/overlay/rtk-000-001 (copy).json~ b/src/en-GB/overlay/rtk-000-001 (copy).json~ new file mode 100644 index 0000000..f64a121 --- /dev/null +++ b/src/en-GB/overlay/rtk-000-001 (copy).json~ @@ -0,0 +1,36 @@ +{ + "name": "Traffic HAT", + "manufacturer": "Ryanteck LTD.", + "url": "http://www.ryanteck.uk/", + "buy": "http://www.ryanteck.uk/", + "description": "A quick and easy way to learn the basics of GPIO on a budget. All in a nice HAT.", + "pincount": 40, + "pin": { + "15": { + "name": "LED1 / Green", + "direction": "output", + "active": "high" + }, + "16": { + "name": "LED2 / Amber", + "direction": "output", + "active": "high" + }, + "18": { + "name": "LED3 / Red", + "direction": "output", + "active": "high" + }, + "22": { + "name": "Button", + "direction": "input", + "active": "high" + }, + + "29": { + "name": "Buzzer", + "direction": "output", + "active": "high" + } + } +} diff --git a/src/en-GB/overlay/traffic-hat.json b/src/en-GB/overlay/traffic-hat.json new file mode 100644 index 0000000..f64a121 --- /dev/null +++ b/src/en-GB/overlay/traffic-hat.json @@ -0,0 +1,36 @@ +{ + "name": "Traffic HAT", + "manufacturer": "Ryanteck LTD.", + "url": "http://www.ryanteck.uk/", + "buy": "http://www.ryanteck.uk/", + "description": "A quick and easy way to learn the basics of GPIO on a budget. All in a nice HAT.", + "pincount": 40, + "pin": { + "15": { + "name": "LED1 / Green", + "direction": "output", + "active": "high" + }, + "16": { + "name": "LED2 / Amber", + "direction": "output", + "active": "high" + }, + "18": { + "name": "LED3 / Red", + "direction": "output", + "active": "high" + }, + "22": { + "name": "Button", + "direction": "input", + "active": "high" + }, + + "29": { + "name": "Buzzer", + "direction": "output", + "active": "high" + } + } +} From a5a2103d79fe54d003fa5cb6bf3016342d5e5d50 Mon Sep 17 00:00:00 2001 From: Ryan Walmsley Date: Mon, 6 Apr 2015 19:51:08 +0100 Subject: [PATCH 4/4] Fixed the auto save from gedit --- src/en-GB/overlay/rtk-000-001 (copy).json~ | 36 ---------------------- 1 file changed, 36 deletions(-) delete mode 100644 src/en-GB/overlay/rtk-000-001 (copy).json~ diff --git a/src/en-GB/overlay/rtk-000-001 (copy).json~ b/src/en-GB/overlay/rtk-000-001 (copy).json~ deleted file mode 100644 index f64a121..0000000 --- a/src/en-GB/overlay/rtk-000-001 (copy).json~ +++ /dev/null @@ -1,36 +0,0 @@ -{ - "name": "Traffic HAT", - "manufacturer": "Ryanteck LTD.", - "url": "http://www.ryanteck.uk/", - "buy": "http://www.ryanteck.uk/", - "description": "A quick and easy way to learn the basics of GPIO on a budget. All in a nice HAT.", - "pincount": 40, - "pin": { - "15": { - "name": "LED1 / Green", - "direction": "output", - "active": "high" - }, - "16": { - "name": "LED2 / Amber", - "direction": "output", - "active": "high" - }, - "18": { - "name": "LED3 / Red", - "direction": "output", - "active": "high" - }, - "22": { - "name": "Button", - "direction": "input", - "active": "high" - }, - - "29": { - "name": "Buzzer", - "direction": "output", - "active": "high" - } - } -}