Electronics basics: Ohm's law

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.

And yes, this post does contain garden hoses…

Continue reading “Electronics basics: Ohm's law”

Soldering headers to boards

When buying microcontrollers, breakout boards and the like, they often come without headers.

In order to plug these boards into a breadboard, we’ll have to solder some headers on to them.  Doing so is quite easy.

Most boards have 2.54mm pin spacing, so if your board did not come with headers, you’ll find suitable header strips in almost every electronics shop.  Look for something like this: https://littlebirdelectronics.com.au/products/40-pin-header-terminal-strip

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.

Continue reading “Soldering headers to boards”

Arduino traffic lights simulator, part 4

Welcome back.

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.

Additional parts needed this time:

Continue reading “Arduino traffic lights simulator, part 4”

Arduino traffic lights simulator, part 3

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.

Continue reading “Arduino traffic lights simulator, part 3”

Arduino traffic lights simulator, part 2

Welcome back.

In the previous part, I showed you how to connect the circuit for the traffic lights simulator.  This time, I’ll show you the sketch to control them.

If you do not have the Arduino software installed already, it can be downloaded from the Arduino website.  You’ll need the Arduino IDE, I have not tested any of this with the Online IDE.

Continue reading “Arduino traffic lights simulator, part 2”