Arduino Tutorial

By LiterallyTheOne

0: Introduction

Arduino Tutorial, intro

Why Arduino?

  • Great and easy
  • Large supportive community
  • Hobbyists
  • Industry
By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, intro

Basic examples

  • Blink LED project
  • Traffic Light controller
By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, intro

Smart Plant Watering system

By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, intro

Automatic Night Lamp

By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, intro

Distance Measurement

By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, intro

Robotics

By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, intro

Home Automation

By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, intro

Weather station

By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, intro

IoT

By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, intro

Wearables

By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, intro

What is Arduino?

  • Open-source
  • Electronic platform
    • Hardware: Uno, Nano, Mega, etc.
    • Software: Arduino IDE
  • Best tool to learn electronics
By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, intro

Arduino Uno

  • AVR: Atmega328P
  • Arduino framework
By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, intro

GPIO

  • Digital: 14 (D0-D13)
  • Analog: 6 (A0-A5)
By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, intro

Blinking LED

  • Hello World
  • LED that blinks
By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, intro

Simple LED

  • Outputs/Leds/LED
  • Sources/Fixed voltage
  • Sources/Ground
  • Passive/Resistors/Resistor
By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, intro

Connect LED to Arduino Uno

By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, intro

PlatfromIO project

By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, intro

main.cpp

#include <Arduino.h>

// put function declarations here:
int myFunction(int, int);

void setup() {
  // put your setup code here, to run once:
  int result = myFunction(2, 3);
}

void loop() {
  // put your main code here, to run repeatedly:
}

// put function definitions here:
int myFunction(int x, int y) {
  return x + y;
}
By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, intro

Remove unnecessary lines

#include <Arduino.h>

void setup()
{
}

void loop()
{
}
By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, intro

Explaning functions

  • setup:
    • Initialization
    • Runs one time
  • loop:
    • Logic
    • While True
By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, intro

Pin Mode

  • pinMode: Set the mode of a pin
    • INPUT
    • OUTPUT
  • In setup
pinMode(13, OUTPUT);
By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, intro

Blinking

  • digitalWrite: Write a digital value on a pin
    • High
    • LOW
  • In loop
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(500);
By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, intro

Full code

#include <Arduino.h>

void setup()
{
  pinMode(13, OUTPUT);
}

void loop()
{
  digitalWrite(13, HIGH);
  delay(500);
  digitalWrite(13, LOW);
  delay(500);
}
By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, intro

Build

  • Tick button
    • Top right
    • Bottom left
  • .pio/build/uno/firmware.hex
By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, intro

Upload firmware

  • Right click on Arduino Uno
  • mega328: load firmware
  • select the path
  • Start simulation
By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, intro

Output

By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, intro

By Ramin Zarebidoky (LiterallyTheOne)

<https://projecthub.arduino.cc/lc_lab/automatic-watering-system-for-my-plants-e4c4b9>

https://projecthub.arduino.cc/ashish80/distance-measuring-device-using-ultrasonic-sensor-8989fb

https://projecthub.arduino.cc/lee_curiosity/how-to-build-6-dof-robot-arm-from-dfrobot-kit-f14fca

https://projecthub.arduino.cc/lakshyajhalani56/home-automation-using-arduino-relay-bluetooth-42635c

https://projecthub.arduino.cc/dnbakshi07/mini-weather-station-using-arduino-nano-8bf261

https://docs.arduino.cc/arduino-cloud/guides/overview/