Getting Started with RTk Traffic HAT

The Traffic HAT is designed for beginners to teach the basics of programming the real world with a traffic light sequence of LEDs. The HAT has 3 on-board LEDs (Red, Yellow, Green) with a push button and piezo buzzer.

The Traffic HAT Comes as a half soldered, half kit package. The 40 way header, HAT EEPROM circuit and resistors for the button are pre soldered on the bottom side. You will be required to solder the 3 LEDs, Button and Buzzer.

Assembling the Kit

You will need to solder some of the components to the Traffic HAT before use. For this you will need to the following parts:

  • Traffic HAT Kit
  • Soldering Iron
  • Solder
  • Sponge/Brass Sponge
  • Snips
  • Blu Tack (optional)

Step 1 – First, we are going to solder the LEDs to the Traffic HAT Kit, LED1, LED2 and LED3. Where Green LED is connected to LED1, Yellow to LED2 and Red to LED3. You will see on the traffic HAT board that for each LED there are two through hole solder tabs, one is a circular tab and one is a square solder tab.

The circle through hole solder tab is the positive leg of the LED also known as the anode. Insert the LEDs in order to the Traffic HAT PCB, the longest leg on the LED is the anode (positive) and the shortest is the cathode (ground).

Note: You can affix the components in place using some blu tack or by bending the legs of the LEDs before soldering as per the below image

Step 2 – Now insert the switch into the S1 through hole solder pads. The switch will only be able to be inserted in in one direction and it doesn’t matter which way round the pins are, since they are the same on both sides of the switch. You may have to bend the legs slightly inwards to insert the switch.

Step 3 – Lastly, insert the piezo buzzer into the BUZZ through hole solder pads on the Traffic HAT PCB. You can see there is a + symbol to indicate where the positive leg of the buzzer goes through. The positive leg on the buzzer is the longest leg, also indicated by the sticker on the top of the buzzer.

Note: The buzzer may not sit flush with the PCB, therefore you will need to bend the longest leg slightly and insert it in as far as it will go

Step 4 – Now solder all the legs on the underside of the PCB board, making sure you apply enough solder to make good contact between components.

 

Getting Started

Now that we have soldered all the components to the Traffic HAT we can test the board using a Python demo program. First of all, insert the Traffic HAT on top of your Raspberry Pi GPIO pins, making sure it is firmly inserted to make good contact with the GPIO header as shown below.

Power up the Raspberry Pi and then connect to the internet using either Wi-Fi or an Ethernet connection. To download the demo code from our GitHub repository, open up a terminal window and then type in the following command:

git clone https://github.com/PiSupply/Ryanteck.git

Navigate to where the Python demo code is:

cd Ryantek/RTK\ Traffic\ HAT/Software/python/

Then you can run the Traffic HAT demo program by typing in the following:

python trafficLightDemo.py

You should see the green LED light up; then press the switch and it will cycle through the traffic sequence from green to red and back to green again. To repeat the process simply press the switch again.

First published at 3:02pm on August 16, 2018
Last updated at 3:02pm on August 16, 2018