Last Updated: 22/05/2024

Arduino/C++ Lessons

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 langauges 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 Tradional Language Course.

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

Basics of C++ - Traditional Language Learning

These C++ lessons are lessons in learning C++ in the way that a traditional programmer would learn to program any computer language. The initial sections may not have any blinking LED's, but it is designed to give a good understanding of programming structure to enable the programmer to understand the code that others have written as well as understanding the various errors that occur.

Although C++ is used by Arduino IDE and desktop programming IDE's and a lot of the syntax and structure is the same. Desktop programming tends to output to the screen in a way that the Arduino IDE does not makng a lot of code examples difficult to understand for beginners.

A simple example is the" Hello World" code below, Arduino IDE on the left and desktop C++ on the right.

C++

With all the lessons I have tried to reuse as much of the previous lessons as possible, introducing new items lesson by lesson, while reinforcing what has been learnt in earlier lessons.

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
Lesson 1 Getting Started

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.

Lesson 2 Syntax and Serial Monitor

Download the code for Lesson 2

Ascii Table

Lesson 3 Controlliong timings with if() and millis()

Download the code for Lesson 3

 

Lesson 4 Digital Pins digitalWrite()

Download the code for Lesson 4

Click image for larger versionLesson 4 Circuit Diagram

 

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 as a reference.
Please be aware that this is a hobby that fits around work so please be patient.