Intro

description

Arduino is an open-source electronics platform based on easy-to-use hardware and software. Arduino boards are able to read inputs - light on a sensor, a finger on a button, or a Twitter message - and turn it into an output - activating a motor, turning on an LED, publishing something online. You can tell your board what to do by sending a set of instructions to the microcontroller on the board. To do so you use the Arduino programming language (based on Wiring), and the Arduino Software (IDE), based on Processing.

Getting Started

Resources

Setting up Arduino

Arduino Board

picture 0

  1. Microcontroller - This is the brain of an Arduino and is the component that we load programs into. Think of it as a tiny computer, designed to execute only a specific number of things.
  2. USB port - Used to connect your Arduino board to a computer.
  3. USB to Serial chip - The USB to Serial is an important component, as it helps translate data that comes from, e.g., a computer, to the onboard microcontroller. This is what makes it possible to program the Arduino board from your computer.
  4. Digital pins - Pins that use digital logic (0,1 or LOW/HIGH). Commonly used for switches and to turn on/off an LED.
  5. Analog pins - Pins that can read analog values in a 10-bit resolution (0-1023).
  6. 5V / 3.3V pins - These pins are used to power external components.
  7. GND - Also known as ground, negative, or simply -, is used to complete a circuit, where the electrical level is at 0 volts.
  8. VIN - Stands for Voltage In, where you can connect external power supplies.

Software Environment

PlatformIO

Wokwi ESP32, STM32, Arduino Simulator

Arduino Maker Workshop VS Code Extension

Programming the Arduino

Arduino API

The Arduino API, aka the “Arduino Programming Language”, consists of several functions, variables and structures based on the C/C++ language.

Program Structure

Every Arduino program needs two functions: void setup() and void loop().

  • void setup() - this function executes only once, when the Arduino is powered on. Here we define things such as the mode of a pin (input or output), the baud rate of serial communication or the initialization of a library.
  • void loop() - this is where we write the code that we want to execute over and over again, such as turning on/off a lamp based on an input, or to conduct a sensor reading every X second.
void setup() {
  // put your setup code here, to run once:
 
}
 
void loop() {
  // put your main code here, to run repeatedly:
 
}