Chapter 2: Building a Traffic Lights Control System
In the previous chapter, we set up TinyGo and our IDE, and we now know how to build and flash our programs to the Arduino UNO. We are now going to utilize this knowledge to go one step further.
In this chapter, we are going to build a traffic lights control system. We are going to split the project into small steps, where we build and test each component. At the end, we are going to put everything together. We will be using multiple LEDs, a breadboard, GPIO ports, and a button to interrupt the normal flow to switch pedestrian lights to green. By the end of the chapter, you will know how to control external LEDs, read the state of a button, use GPIO ports, how to distinguish resistors, and how to utilize Goroutines in TinyGo.
In this chapter, we are going to cover the following topics:
- Lighting an external LED
- Lighting a single LED when a button is pressed
- Building traffic lights
- Building traffic lights with pedestrian lights