2015-11-10 02:05:51 +08:00
|
|
|
<!--
|
|
|
|
---
|
2016-01-31 19:03:17 +08:00
|
|
|
class: board
|
|
|
|
type: multi
|
2015-11-10 02:05:51 +08:00
|
|
|
name: Traffic HAT
|
|
|
|
manufacturer: Ryanteck LTD.
|
2016-06-25 05:33:02 +08:00
|
|
|
image: 'traffic-hat.png'
|
2015-12-30 01:49:41 +08:00
|
|
|
description: A quick and easy way to learn the basics of GPIO on a budget. All in a nice HAT.
|
2015-11-10 02:05:51 +08:00
|
|
|
url: http://www.ryanteck.uk/store/traffichat
|
|
|
|
buy: http://www.ryanteck.uk/store/traffichat
|
2015-12-30 01:49:41 +08:00
|
|
|
formfactor: 'HAT'
|
2015-11-10 02:05:51 +08:00
|
|
|
pincount: 40
|
2015-12-30 01:49:41 +08:00
|
|
|
eeprom: yes
|
2015-11-10 02:05:51 +08:00
|
|
|
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
|
|
|
|
-->
|
|
|
|
#Traffic HAT
|
|
|
|
|
|
|
|
###A quick and easy way to learn the basics of GPIO on a budget. All in a nice HAT.
|
|
|
|
|
|
|
|
```python
|
|
|
|
import RPi.GPIO as IO
|
|
|
|
from time import sleep
|
|
|
|
|
|
|
|
IO.setmode(IO.BCM)
|
|
|
|
|
|
|
|
#Lights
|
|
|
|
IO.setup(22,IO.OUT)
|
|
|
|
IO.setup(23,IO.OUT)
|
|
|
|
IO.setup(24,IO.OUT)
|
|
|
|
|
|
|
|
#Buzzer
|
|
|
|
IO.setup(5,IO.OUT)
|
|
|
|
|
|
|
|
#Button
|
|
|
|
IO.setup(25,IO.IN,pull_up_down=IO.PUD_UP)
|
2016-01-31 19:03:17 +08:00
|
|
|
```
|