Skip to content

Mark-MDO47/ArduinoClass

Repository files navigation

Arduino Class

For an Arduino class 2023; FabLab will be first
Author: Mark Olson
To all who attended the first Arduino Class at FabLab: thanks and I hope you had fun while learning a few things!

Table Of Contents

Lesson Plan

Top
Below is the lesson plan for the class.

Lesson Description Image
PleaseKnowSomeC/C++ If you know C/C++ you are good to go for this Arduino class! If you have programmed Java, Python, or some other text-based programming language, you should be ready to start this Arduino class and pick up C-language on the way. If you have never done any programming in any language, please sign up for the C for Arduino Class. One or the other of programming experience or the C for Arduino Class is a pre-requisite for the Arduino class. Image of Kernighan and Ritchie C language book
00_InstallArduinoIDE Install the Arduino IDE
Brief discussion of the venerable C/C++ language
Quick introduction to schematics and Fritzing
If possible, please read this lesson and install the Arduino IDE before class!
Image of Arduino IDE
01_BlinkingLED Blink some simple LEDs
Control blinking using a button
Display diagnostic messages using USB serial port
YouTube: https://youtu.be/c5UH3J40uWE
YouTube: https://youtube.com/shorts/qGxECSMQtAQ
Discusses ways to power Arduino, program persistence through power-cycling, and use of PROGMEM to lower usage of RAM.

External Image of Arduino Nano from CircuitsToday.com
CircuitsToday.com picture of Arduino Nano
Image of Blinking LED part B
02_PersistenceOfVision Fool your vision system with RGB LEDs
Control Arduino with button and with keyboard via USB serial port
Consists of setup and four projects, plus "extra credit" and "persistence of vision spinning stick"
Youtube: https://youtu.be/UdA5ehl802k
Discusses WS2812B addressable RGB LEDs, the FastLED library, binary numbers and boolean algebra, power consumption and wire guage considerations, and storage of configuration information in EEPROM.
TLDR discusses the serial protocol for WS2812B.
Image of 02_PersistanceOfVision PartA: setup with LED Stick Blinking
Image of spinning LED Stick Blinking Hello World
03_SonarRangeDetector Measure distances with ultrasonic waves to control a zillion LEDs
Consists of one project plus "Extra Fun" using really large collections of RGB LEDs
Youtube: https://youtu.be/0KehSIJmKcs
Discusses HC-SR04 Ultrasonic Range Finder, the ULTRASONIC library, and the famous DemoReel100 RGB LED demonstration program.
TLDR discusses speed of sound in air at different temperatures and also the Theremin musical instrument.
picture of HC-SR04
picture of 241 LED disk
04_TheFinale Add sound and Bluetooth to our Sonar Range Detector and DemoReel100
Also do the same thing with Voice Commanding instead of Sonar Range Detector
A "sound add-on" takes this project close to the maximum practical size for breadboarding using this haywire approach. The voice commanding takes it even further, requiring two Arduino Nanos.
Youtube: https://youtu.be/G7ARC0xHXRg
Youtube: https://youtu.be/M8Xc4aVh5Hc
Discusses the YX5200 Sound Module using SD Card with sound files and the KCX_BT_EMITTER Bluetooth Transmitter.
Discusses the DF2301QG voice commanding module.
Image of 04_TheFinale: Voice Commands setup
Image of 04_TheFinale: Sound and Bluetooth Modules
Image of 04_TheFinale: Voice Command Module
Image of 04_TheFinale: Voice Command Demo Reel with smiley face
05_ThatIsNotAll These are a few of my favorite things...
Youtube: https://youtu.be/VJ-WH86G7Pg
Image of Mark with Mad Scientist Goggles
99_Resources Repository of class information.

External Image of Long Room Library at Trinity College from lh3.googleusercontent.com
Image of Long Room Library at Trinity College
ArduinoCode Repository of code for the class projects. Image of Arduino IDE

Parts Kit Provided

Top
For this class I will provide a "kit" for each student station. I have labeled them "Kit 1" through "Kit 6"; Kit 1 is intended for me and the others are available for the class. Each kit includes all the major components for all the projects of our class except the "Extra Fun" section of the 03_SonarRangeDetector, for which we will share some extra equipment that I will bring. The Kit parts are still in the wrappers (except for the RGB LED Strips; I needed to solder on some wires) so if some do not work we will need to double up; maybe I would sacrifice my kit.

Image of Kits for Arduino Class

Each of these kits costs about $8 today and I think you will experience that there are many exciting Arduino projects that can be performed inexpensively!

Part Cost on March 2023 Source used
Arduino Nano $2.35 aliexpress.com
Solderless Breadboard < $2 protosupplies.com
WS2812B RGB 8-LED Strip < $2 protosupplies.com
HC-SR04 Sonar Range Detector < $2 protosupplies.com
Button ~ $0.10 amazon.com
200 Ohm resistor ~ $0.10 digikey.com
LED ~ $0.10 amazon.com

You should then be able to do all of the standard projects. For the extra credit projects I will bring all the following for our use, to be moved from station to station.

  • connectors, clips, harnesses, and wires
  • large RGB Color LED Disks (93 LEDs and 241 LEDs) plus battery and UBEC power convertor (I will provide some to share between student stations)
  • a breadboard with the sound circuitry (YX5200 sound module and KCX_BT_EMITTER Bluetooth module) for the finale project
  • a breadboard with an extra Arduino Nano and a voice recognition and command module (DF2301QG) for the finale project

Some other items used in the extra credit projects

Top
These will be provide to share between the stations.

Part Image
Mirror Image from bedbathandbeyond.com of a mirror for viewing persistence of vision
Large (93 or 241 LED) WS2812B disk Image of 241 LED WS2812B Disk
Battery, Universal Battery Eliminator Circuit (UBEC), (Frankenstein) knife switch Image of UBEC Power Setup
"Spinning Stick" Persistence of Vision wand with 8 WS2812B LEDs Image of Sideview of Spinning Stick
Bluetooth and Sound Circuitry Image of Bluetooth and Sound Circuitry
Voice Command module Image of Voice Command module
Bluetooth Speaker Image of Bluetooth Speaker

Some other things you might see in the class

Top
These will (probably) be present to play with in the class.

Part Image
Park the Car box with 8 WS2812B LEDs and HC-SR04 Ultrasonic Range Detector Image of Park-the-Car box
Graduation Cap with 372 WS2812B LEDs controlled by 4 Arduino Nanos Image of Graduation Cap
SciFi Rubber Band Gun with 144 WS2812B LEDs and Bluetooth sound Image of SciFi Rubber Band Gun
SteamPunk Goggles with 32 WS2812B LEDs Image of SteamPunk Goggles
"... neither confirm nor deny" Coaster Image that can neither be confirmed nor denied

Please Bring USB Cable

Top
Please try to bring a USB cable to connect from your laptop to the Arduino Nano. The Nano has a USB Mini-B female so your cable should end in USB Mini-B male; for more information see the references in lesson 01_BlinkingLED. I will have at least enough USB-A to USB Mini-B cables available for the 5 student stations, but if your laptop uses USB-C or anything but USB-A you will need to cover the gap.

The link below shows what many USB cables male and female connectors and sockets look like.

Learning C and Cplusplus

Top
One thing I learned when teaching the first class is that things will move much faster if everyone has some basic experience with a text-based programming language.

The Arduino IDE uses C and C++ languages (except for some of the I/O libraries, as explained later).

  • If you have experience in any text-based programming language - Python, Java, or other programming languages - you will probably be able to catch on to the parts of C and C++ used in this class quickly.
  • You can easily pick up on the few parts of C++ used in this class if you have some knowledge of C (or even Python or Java or other languages)
  • One or the other of programming experience or the C for Arduino Class is a pre-requisite for the Arduino class.

One factor to consider when learning C/C++ for this class: Arduino does not implement the standard "printing" etc. functions - not for C (printf and scanf) and not for C++ (IO Streams). Arduino uses relatively simple "Serial" methods such as Serial.begin, Serial.print and Serial.println for output; Serial.available and Serial.read and Serial.read variations for input. See the Serial Main Page for more details.

  • If you want to learn the full languages to further your career, you will probably want to learn the standard C and C++ methods at the same time as learning enough C and C++ for this class. There is a lot to learn about C and C++!
  • If you want to get started by doing some fun Arduino projects from this class you can skim the standard C and C++ methods, knowing that they are not used for these projects. You can return to the standard methods later.

Here are some web resources for learning the C language:

Here are a few of the highly rated free C-language ones from the above lists. I have not taken these classes myself but at a quick glance they seem OK.

There are many books on learning the C language. I have no experience with most of them.
The following book is how I learned the C language, back when dinosaurs ruled the earth. I really like its approach of building up knowledge in blocks such that you can use them immediately and they all fit together.

  • The C Programming Language by Brian W. Kernighan and Dennis M. Ritchie

If you search you might find the "mass-market paperback" of The C Programming Language at around $20 or maybe a used copy for even less.
If you are going to get a copy, I suggest you try to get the latest edition. Since you will be investing the time, you might as well be close to up-to-date (2nd edition is Copyright 2012).

As an aside: some of the projects will use binary arithmetic and Boolean logic to implement simple data compression. We will do a quick discussion on how this code works when the time comes. This is another one of those topics that is important but could be skimmed if you just want to enjoy the project and study it later.

There is a quick discussion of binary and other numbering systems in the resources page:

Binary and Boolean are discussed more fully in Wikipedia:

Kudos

Top
By the way, Kudos to my son Carl for Alpha-Testing this class. You will see some images and videos of his work and may even catch a glimpse of him or me in the videos.