This is a post to explain the basics of electronics, starting with Ohm’s law.
Ohm’s law describes the relationship between the voltage, current and resistance in a circuit, and it is one of the basic physical laws that controls how circuits work.
We need to understand this law in order to select the correct resistors to use in our circuits and to control how much current will flow. We also need to know how much power our circuit will draw and how much power each component will dissipate. Too much power and things will heat up too much, burning out.
These strips snap off easily to the desired size, just double check that you have the correct number of pins before you snap. As an example, Adafruit’s Huzzah ESP8266 breakout board have two rows of 10 pins each, in addition to 6 pins for FTDI.
This time I will show the basics of how to connect a push button to the traffic light simulator circuit and how to read it from within an Arduino sketch. If you haven’t read parts 1, 2 and 3 yet, I recommend you do so first as it will make it easier to follow the examples.
For this demonstration, we’ll use a simple push button like this. They have four pins, connected together two by two. Usually the two pins on either side are connected together, and pushing the button will connect them to the two pins on the other side. If you’re in doubt, use a multimeter to check which pins are connected together.
In the previous two parts, I have shown how to build a 2-way traffic light and how to write a sketch to control it.
This time we’ll rewrite the sketch to use state tables.
In microcontroller programming, we are often dealing with a set of well defined states. State tables describe what each state means, rules for transitioning between the different states, for what is allowed and what is expected. Keeping this in a set of tables helps keep the code simple by avoiding a big, tangled mess of if-else statements. This, in turn keeps the code smaller so we can do more with the rather limited memory on the microcontroller.