Learning Basic Electronics with Arduino


I have seen with interest everything that smart people on the Internet have done with small programmable micro PCs and microcontrollers. While the desire to do ‘something’ with them has always been there I’ve never come up with a project that I wanted to figure out and have thus left learning about this world of enthusiast-accessible electronics as something for another time. Recently I was chatting with my brother, who teaches this stuff, and that conversation led to an Amazon purchase and him sending me one of the assignments for his students.

I never learned electronics in school. I took a weird path into the software industry and through my career. I’ve seen different sides of it and had a chance to be both in hands-on and leadership roles over the past couple of decades. But it’s all been software. Hardware has always seemed a little bit like magic.

PXL_20240202_050040427.MP.jpg

I pulled the trigger and ordered a kit so I could start to wrap my head around this stuff. PCBs and jumper wires, and resistors and sensors, and LEDs and all the rest of it. There’s a bunch of stuff in the kit and a nice long PDF doc to walk me through the basics of it in a way that should minimize the chances of me summoning the blue smoke of failure from blowing out a component.

The first couple of projects involved me wiring up some very basic circuits and then lighting up an LED. First a single LED and subsequently an RGB LED with three separate LEDs in the same package.

PXL_20240202_070337072.jpg

The code for this is all written in C — because yes, this is also going to be a software project. In the spirit of my journey to learn more in public, all the code I write along the way will get posted to this GitHub repository as a record for me, and in the off case it might be helpful to someone else.

For this first project I decided to challenge myself to improve the code that was provided in the sample. The original code is written to simply show how to cycle the power level being fed to the LED from the Arduino using the analogWrite function. At its most basic level this function provides a numeric value to set the amount of current that will flow down a particular output pin. The value is a int value between 0 and 255.

In my sample I changed the default code which consists of a series of three for loops with hard-coded values for the Red, Green and Blue LEDs to cycle through and created a new function that would cycle between arbitrary values for each of the three LEDs at a specified delay.

The goal was to make a more reusable piece of code that wasn’t hard-coded to specific values, remind myself some basics of how to code in C, and still replicate the functionality of the original example and beyond.

Some basic things I learned from this example:

  • Using Serial.print / Serial.println are good ways of reporting back debugging information from the board to the PC where you’re working on the code. But the piece of information I missed somehow is that you need to include the instruction Serial.begin() in your setup function
  • Pay close attention to the columns and gap in the breadboard. The pins are only linked in a column up to a gap line. I’ve since learned this is called the ravine.
  • There are a lot of very small parts in this kit. The box they came in was fine for transport, but sucks as a permanent storage place. I’ll need to do something about that very shortly to make sure that I neither misplace nor lose any of the tiny bits and bobs