INTRO TO MICROCONTROLLERS WITH
ARDUINO
JULIEN DE LA BRUÈRE-TERREAULT
©2017, Julien de la Bruère-Terreault drgfreeman@[Link] This work is licensed under a Creative Commons Attribution-ShareAlike
MICROCONTROLLERS AND DEVELOPMENT BOARDS
Microcontrollers are integrated circuits (IC) that includes a ATmega 32U4
microcontrolle
central processing unit (CPU), memory and input / output r
peripherals (GPIO) on a single chip. Most microcontrollers also
include Analog-Digital Converters (ADCs), timers and
interrupts.
Development boards are printed circuit boards combining, in a
practical format, a microcontroller with features such as :
GPIO pins or connectors ARM Cortex
M4
Voltage regulator microcontrolle
r
Built-in LEDs
USB interface
Various board specific features
Teensy 3.5 Arduino Leonardo
development development board
board
©2017, Julien de la Bruère-Terreault drgfreeman@[Link] This work is licensed under a Creative Commons Attribution-ShareAlike
POPULAR DEVELOPMENT BOARDS
Arduino Uno R3 Arduino Mega Arduino Teensy 2.0
ATmega 328P ATmega 2560 Leonardo/Micro ATmega 32U4
8 bits - 5V logic
ATmega 32U4
level
Arduino Due Teensy 3.x NodeMCU Adafruit ESP32
ARM Cortex M3 ARM Cortex M4 ESP2866 ESP32
32 bits - 3.3V logic
Wi-Fi chip / Microcontroller Wi-Fi / Bluetooth /
Microcontroller
level
©2017, Julien de la Bruère-Terreault drgfreeman@[Link] This work is licensed under a Creative Commons Attribution-ShareAlike
GETTING STARTED WITH ARDUINO
Arduino is an open source, computer hardware and software
company, project, and user community that designs and
manufactures microcontroller kits for building digital devices
and interactive objects that can sense and control objects in
the physical world. The project's products are distributed as
open-source hardware and software. (Wikipedia)
Arduino resources on [Link] :
Getting started guide
Arduino introduction
Arduino tutorials
How it works: Foundations
Language reference
Arduino IDE
©2017, Julien de la Bruère-Terreault drgfreeman@[Link] This work is licensed under a Creative Commons Attribution-ShareAlike
RECOMMENDED MATERIAL
Arduino board: Uno, Leonardo and Micro all have a 5V logic
UNO: Most popular, versatile
level.
Leonardo: More I/Os, more interrupts than Other material:
Uno USB cable
Micro: Same as Leonardo in a smaller Prototyping breadboard
format. Jumper wires
Uno and Leonardo share the same form factor
LEDs
and are compatible with a variety of third
party shields. Resistors (220 ohm, 10K ohm)
Micro is cheap and compact, perfect for Potentiometers (variable resistor, 10K ohm)
permanent setups. Requires welding of Pushbuttons
header pins or wires directly to the board.
Power supply or batteries
Leonardo and Micro can emulate a keyboard
or mouse when connected to a computer.
©2017, Julien de la Bruère-Terreault drgfreeman@[Link] This work is licensed under a Creative Commons Attribution-ShareAlike
POWER CONSIDERATIONS
Adruino Uno / Leonardo
Powering the Arduino (5V boards):
USB power: provides enough power for the Arduino and low
current peripherals (e.g. single LEDs).
Vin pin / barrel plug : 7-12V input powering the on-board
voltage regulator.
Power source selection is automatic
Powering peripherals: In
5V pin: Output of on-board voltage regulator, ~250 mA max. Adruino Micro
Out
3.3V pin: Regulated output, 50 mA max.
GPIO pins: 20 mA max per pin.
An external power source is recommended for peripherals
drawing more than 250 mA total. Motors and servos definitively
need to be powered by an external power source (power supply
or batteries).
©2017, Julien de la Bruère-Terreault drgfreeman@[Link] This work is licensed under a Creative Commons Attribution-ShareAlike
PIN MAPPING DIAGRAMS (PINOUT)
The pinout diagrams provide information about the
different functions of each pin of the microcontroller.
Analog-Digital Converter (ADC) “Analog Pins”
Pulse Width Modulation (PWM) enabled pins
Serial communications (TX/RX, SDA/SCL, SPI) pins
Interrupts and Pin Change Interrupts (INT/PCINT)
ATmega port and bit number for direct access
The diagrams are available for each board on the
Arduino products page.
©2017, Julien de la Bruère-Terreault drgfreeman@[Link] This work is licensed under a Creative Commons Attribution-ShareAlike
PROGRAMMING THE ARDUINO
Arduino IDE
Arduino programs are developed on a personal computer
(Windows, Mac, Linux) using the Arduino IDE (Interactive
Development Environment).
When ready, the program is compiled and then uploaded to
the Arduino flash memory via the USB connection or a through
some dedicated pins (ICSP).
The Arduino loads and runs its program as soon as it is
powered.
The Arduino can run without connection to the computer but
can communicate with the computer over a serial connection
through the USB cable (access via the IDE’s Serial monitor).
Compile and
Upload Serial monitor in the Tools menu
buttons
©2017, Julien de la Bruère-Terreault drgfreeman@[Link] This work is licensed under a Creative Commons Attribution-ShareAlike
A TYPICAL ARDUINO PROGRAM (SKETCH)
[Link] example
The main program is stored in an Arduino sketch
“sketch” (.ino file)
The sketch can optionally include:
Declaration of global variables
Functions defined in the sketch file
Functions / classes defined in a separate file
within the sketch folder
Functions / classes defined in external libraries
The sketch minimally includes two functions:
The setup() function runs only once
The loop() function runs continuously
©2017, Julien de la Bruère-Terreault drgfreeman@[Link] This work is licensed under a Creative Commons Attribution-ShareAlike
WHERE TO BUY
[Link] (CAN) [Link]
RobotShop (CAN) [Link]
Adafruit (US) [Link]
SparkFun (US) [Link]
[Link]
[Link]
©2017, Julien de la Bruère-Terreault drgfreeman@[Link] This work is licensed under a Creative Commons Attribution-ShareAlike