Last Updated 07/05/2026

Arduino/C++ Lessons Various Arduino tutorial courses
Learning to program takes time and patience. For many it means learning not only the programming side but the electronics as well. By the time I started to program the Arduino I had already learnt a number of different languages and so followed the tradition way of learning to program.
That means learning the core structures of the language and then using that core to control components. It's the way I have always learnt and if I ever have to learn another language it is the method I would always choose. The upside of this method is you can start with just the Arduino and add a starter kit later.
The downside is that you don't get to see LED's turning on and off or press buttons etc in the early lessons. That all comes once you understand the language. However, you will be able to understand code quicker and this has advantages later as you wish to add other peoples code into your own projects.
Click here for the Traditional Language Course.
For extra info on using the ESP32 boards click here.
Getting Started and the Arduino IDE
Preperation 1: Getting Started - What you need, Choosing a kit, downloading the Arduino IDE 17/02/2024
How to Download and Install Arduino IDE 14/07/2021
Getting Started - Arduino IDE quick tour (Version 2.3.0 or greater) 15/02/2024
A Tour of the Arduino IDE (Classic Version 1.8) 15/07/2021
Arduino 2.3 IDE Series
I decided to re record and try and improve on the original series of lessons using better cameras and production software.
|
|
Lesson (Click to watch) |
Lesson Resources |
 |
Arduino IDE Arduino Integrated Development Envirment software. The program used to write code and upload it to the Arduino boards.
CH340 Drivers Many boards use the CH340 communication chip and therefore require CH340 drivers to be installed.
Other information:
Windows 11 and CH340 drivers Under Windows 11 there has been a driver issue with a few boards using a certain type of CH340 chip. This includes the UNO and some ESP8266 boards. If you have issues with your board not being recognised this video explains how to fix the issue. |
 |
Basic syntax, line ends, brackets and common errors and how to spot them.
Creating a variable.
The basics of using the Serial Monitor
The differences between sending text and numeric values.
Download the code for Lesson 2
Ascii Table |
 |
How to control program timings using if() and millis()
Controlling multiple items with different timings.
Download the code for Lesson 3
|
Introduction to controlling outputs with digitalWrite().
Using pinMode()
Controlling multiple LED's with different timings. |
Download the code for Lesson 4
Click image for larger version |
 Introduction to controlling inputs.
Introduction to digitalRead() and pull down resistors.
Basic button debouncing and why it is needed. |
Download the code for Lesson 5
Click image for larger version |
This is an extra lesson that has been added to show how to control items with toggle switches with the Arduino UNO, rather than the usually push to contact switches that come in most kits.
As always the code is non blocking (state machine) style code and in the example a pair of LED's are turned on and off although the code can be easily adated to control other items. |
Download the code for Lesson 5b
Technical explanation of the different types of toggle switches
Click image for larger version |
Reading analog Pins with analogRead()
map() function
float variable type
switch() statement
ESP32 analogRead |
Download the code for Lesson 6
Click image for larger version |
Combining Sensors and Outputs.
PIR Sensor
Photoresistor
LED
Relay
if( && ) control structure
Component timers using millis() |
Download the code for Lesson 7
Click image for larger version |
Combining Sensors and Outputs.
2 x IR Sensor
LED's
if( || ) control structure (if(OR))
Component timers using millis() and process control using switch() and State |
Download the code for Lesson 8
Click image for larger version |
Array basics
Using the for() loop
random() |
Download the code for Lesson 9
Click image for larger version |
Servos
Servo Library
individual Servos
Multiple Servos
Servo Speed control
Non blocking Code |
Download the code for Lesson 10
Click image for larger version |
Advanced Servo Control
This lessons shows how to prapare the servo code so that it can be triggered by buttons/sensors/potentiometer etc.
Servo control code is placed in arrays and functions to allow for easy expansion.
Servos speed and direction controlled by buttons
Servo position controlled by potentiometer
This code can control multiple servos.
Non blocking Code |
Download the code for Lesson 11
The circuit remains the same as Lesson 10
Click image for larger version |
Arduino UNO with ULN2003 and 28BYJ-48 Stepper motor tutorial using non blocking (State Machine) examples.
This is the first part of how to use a stepper motor in Arduino projects.
This lesson focuses on the basics of creating non blocking code. |
Download the code for Lesson 12
Click image for larger version
 |
Arduino UNO with ULN2003 and 28BYJ-48 Stepper motor tutorial Part 2 using non blocking (State Machine) examples.
This lessons simplifies the code to a function as well as showing how to change the stepper speed, acceleration and decceleration, repeating movement cycles
as well as showing how to make the stepper move constantly using the function created.
In the examples changes are sent to the stepper using button commands but these could be changed to sensors to suit your project. |
Download the code for Lesson 13
Click image for larger version
 |
How to set up and use External Interrupts with the Arduino UNO.
Part 1 deals with slower speed interrupts and uses the rotary encoder to generate the interrupt.
Different examples of how to use the Rotary Encoder with interrupts are in the sample code. |
Download the code for Lesson 14
Click image for larger version
 |
How to set up and use External Interrupts with the Arduino UNO.
Part 2 deals with reading signals from devices and shows the basics of how to process the signals. |
Download the code for Lesson 15
There is no circuit diagram for this lesson. However the following links may be useful.
Understanding FIFO buffers
DCC decoder circuit
for Arduino UNO/ESP32
|
In this lesson a single button will be used to change the mode in the Arduino sketch allowing the Arduino to change the LED pattern depending on the mode.
The sketch shows how to combine the a debounced button with millis() being used to control the LED pattern timings. |
Download the code for Lesson 16
Click image for larger version
 |
Using the 1602A I2C LCD screen with the Arduino UNO including how to
deal with string padding to get a better display.
ESP32 and I2C 1602A LCD Screen
 |
Download the code for Lesson 17
Click image for larger version

|
In this lesson I will go through the steps and considerations when choosing sensors for a project, in this case a speedometer for a model railway.
The project will use the LCD screen from lesson 17, a debounced button from Lesson 5 and the IR sensors from Lesson 7. |
Download the code for Lesson 18
Click image for larger version
 |
This lesson looks at using the L298N motor driver board to control DC motors.
This lesson includes direction control as well as speed control using PWM.
|
Download the code for Lesson 19
Click image for larger versions
Sketches 1-3 use this circuit

Sketch 4 uses this circuit.
 |
This lesson builds on lesson 19 and uses a joystick to control the speed and direction functions that control the motors in a way that would suit model car control.
|
Download the code for Lesson 20
Click image for larger versions
|
This lesson shows how to add extra input pins to the Arduino using the CD4021BE shift register chip. In this lesson I will add an extra 32 pins but more chips can be added by modding a single line of code.
All code is non blocking, state machine style code.
 |
Download the code for Lesson 21
Additional information and circuit diagrams are available on the CD4021B Shift Register Arduino tutorials page
Click image for larger versions
|
This lesson shows how to add extra output pins to the Arduino using the 74HC595N shift register chip. In this lesson I will add an extra 24 pins but more chips can be added by modding a single line of code.
The lesson creates a apir of simple functions to allow any pin to be set HIGH of LOW in a simple to use manner.
All code is non blocking, state machine style code.
 |
Download the code for Lesson 22
Click image for larger versions
LED's are using 330 Ohm resistors
|
This lesson takes a look at alternative boards to the Arduino UNO and explains a few of the advantages and disadvantategs of different types of boards.
It also explains the differences between 16 bit and 32 bit processing
as well as other issues or advatages between 3.3v and 5v boards.
|
Download the code for Lesson 23
|
This lesson explains how to use Transistors and Mosfets as well as some of the issues to be aware of whe controlling motors.
The lesson also covers PWM control for LED's and motors as well as showing some of the values to look at when choosing a Mosfet or transistor for your project.
|
Download the code for Lesson 24
Click image for larger version

|
This lesson starts to explore Serial communication.
Serial communication can be used to communicate between Arduino boards but also with other devices.
This lesson covers the basics of how Serial communication works as well as showing some of the issues such as the Serial buffers and what happens when they overflow.
|
Download the code for Lesson 25
There is no circuit diagram for this lesson.
You just need an Arduino Uno
If you want to know more details of the technical side of Serial communication take a look at this page on UART basics
Click for m ore information on Ring buffers or FIFO buffers
|
This lesson looks at the basics of sending and receiving data via Serial communication between different types of boards including the issues when communicationg bertween 5v and 3.3v boards.
This lesson also covers some of the differences between using the built in Hardware serial ports and using software serial.
|
Download the code for Lesson 26
Circuit diagram for this lesson (Click image for larger version).

|
This lesson looks how to break down int's and long's into bytes to transmit via Serial.
It also covers the issues of bytes being read in the wring order by creating a packet for the transmission.
Finally to check for data corruption a checksum is then created and added to the data packet.
|
Download the code for Lesson 27
Circuit diagram for this lesson is the same as lesson 26 (Click image for larger version).

|
This lesson starts to cover how to create a network protocol with a slave and master system with communication timing being controlled by the master at all times.
The lessons learnt in creating a simple network protocol helps to understand the basic structure of different types of
communication such as CanBus or CabBus enabling users to understand and integrate with different standards of communication protocols.
The lessons learnt in this video will prepare the way for the next lesson when multiple Uno's will be connected together using RS-485.
Other Resources
Lesson 4 digitalWrite (leds)
Lesson 5 Debouncing Buttons
FIFO (Ring) buffers
|
Download the code for Lesson 28
Circuit diagram for this lesson (Click image for larger version).

|
This lesson combines takes the network protocol lessons learnt in lesson 28 and expands it using RS485 modules to allow up to 32 Arduinos to be connected together with a cable length of up to 1200 metres (4000ft).
The examples show how the Master to Slave communication works but also Slave to Slave and Slave to Master.
These sketches can be adapted to create a fast and efficient communication system allowing boards to not only share data but to send control codes triggering actions by other boards.
The examples given run on 5 boards but this can easily be expanded up to the 32 board limit.
Other Resources
Lesson 4 digitalWrite (leds)
Lesson 5 Debouncing Buttons
FIFO (Ring) buffers
|
Download the code for Lesson 29
Circuit diagrams for this lesson (Click image for larger versions).


|
Part 1 shows the basics of controlling the Nema type stepper motor drivers using micros() instead of microDelay().
Using micros() for timing allows buttons to be or other sensors and even other stepper motors to be controlled while the motor is running.
Other Resources
Lesson 3 controlling timings For more information on the A4988 Stepper motor driver see lastminuteengineers.com/a4988-stepper-motor-driver-arduino-tutorial/ |
Download the code for Lesson 30
Circuit diagram for this lesson (Click image for larger version).

|
Part 2 show how to index stepper motors. Although the examples use Nema 4 wire steppers the code can be adapted for stepper such as the 28BYJ-48 from lesson 12.
In the examples a limit switch will be used for linear indexing while the rotational indexing will be indexed using a hall sensor.
Linear indexing is for things like 3D printers or transfer tables
that have the stepper motor ritation converted to a linear movement.
Rotational indexing if for items such as turntables.
Other Resources
Lesson 3 controlling timings For more information on the A4988 Stepper motor driver see lastminuteengineers.com/a4988-stepper-motor-driver-arduino-tutorial/ |
Download the code for Lesson 31
Circuit diagram for this lesson (Click image for larger version).

|
Part 3 looks at how to control multiple stepper motors running at the same or different speeds and direction at the same time.
Although a CNC shield is used in the example
individual steeper drivers can be set up as per the circuit diagram for this lesson.
Other Resources
Lesson 3 controlling timings For more information on the A4988 Stepper motor driver see lastminuteengineers.com/a4988-stepper-motor-driver-arduino-tutorial/ |
Download the code for Lesson 32
Circuit diagram for this lesson (Click image for larger version).

|
This lesson looks at how to send multiple data types in a single transmission using a structure using struct to create a structure of data types.
This method of transmitting data removes the need to bit shift integers or longs before transmission.
This lesson shows how to send unsigned long, int, byte, Char and String all in one transmission.
Packet headers are also covered in this lesson.
|
Download the code for Lesson 33
Circuit diagram for this lesson is the same as lesson 26/27 (Click image for larger version).

|
For a project I'm working on I am very limited by the number of buttons I can use and due to this limitation I needed to allow each button to have multiple outputs (modes).
As an example a short press gives one output while a long press gives a different output.
Another
example is a bit like when the Caps Lock button is pressed on the keyboard, when pressed other buttons have a different output depending on the mode (Caps Lock) button.
So this lesson looks at different ways to allow a single button to have multiple outputs.
These sketches use millis() for timing to prevent blocking code. For an introduction to using millis for timing see Lesson 3 and Lesson 5
These sketches also use arrays for data storage so see Lesson 9 for the basics on using arrays.
|
Download the code for Lesson 34
The pull down resistors in the circuit should be 4.5k - 10k. In my setup I am using 10k resistors.

|
|
Arduino 1.8 IDE Series
This is the original Arduino C++ course that was created in 2021 using the Arduino Classic (version 1.8 IDE). It is being replaced by the new series.
Lesson 1: Basic sketch layout and how to comment code 15/07/2021
Lesson 2: "Hello World" Basics of printing to Serial Window 17/07/2021
Lesson 3: Using "if else" to control code 19/07/2021
Lesson 4: Using "for loop" to control code 21/07/2021
Lesson 5: Using "switch" to control code 21/07/2021
Lesson 6: Basic Numeric variables, boolean, byte, int, unsigned int, long, unsigned long 23/07/2021
Lesson 7: delay() v's millis(), controlling timing of programs 23/07/2021
Lesson 8: Basic mathematics, addition, subtraction, multiplication and division 27/07/2021
Lesson 9: Basic of creating and using functions 28/07/2021
Lesson 10: Using Global and Local variables 11/08/2021
Lesson 11: Arrays 28/08/2021
Arduino Functions
Functions 1 : digitalWrite() Using digital pins to turn things on and off 05/08/2021
Functions 2 : digitalRead() Reading a digital pin and pullup resistors 11/08/2021
Functions 3 : analoglRead() Reading an Analog pin, converting to Voltage 03/09/2021
Functions 4 : tone() and noTone(), creating sounds with a piezo speaker 24/09/2021
map() function 19/03/2024
How To's
How To 1 : Debouncing buttons 15/09/2021
How To 2 : Multiple HC-SR04 Ultrasonic sensors using bit shifting with 74HC595 05/10/2021
How To 3 : Issues when joining two sketches together 22/10/2021
How To 4 : Creating a Project - Alarm example 25/10/2021
How To 5 : Nema 17 stepper motor using micros() for timing. 08/12/2021
How To 6 : FIFO (Circular) Buffer 29/04/2024
Servo speed control with millis()
Problems and Errors
Windows 11 CVH340 driver issues 10/02/2024
Fixing a Slow IDE 10/02/2024
Arduino IDE Error messages and solutions 30/07/21
Contact
If you have a particular subject you want covered please email the address in this image:
and use Arduino/C++ Lessons Various Arduino tutorial courses as a reference.
Please be aware that this is a hobby that fits around work so please be patient.