Arduino Boards Notes
Arduino Boards Notes
ARDUINO
PROGRAMMING
Department of Electrical and Electronics Engineering
Mar Baselios College of Engineering and Technology, Trivandrum
SKILL DEVELOPMENT PROGRAMME
▪ Future Technology
▪ Amazon Warehouse
▪ Robotic Competitions
SKILL DEVELOPMENT PROGRAMME
WHY ARDUINO..?
TECHNICAL SPECIFICATIONS
ARDUINO TYPES
ARDUINO TYPES
Arduino MKR Zero - SAMD21 Cortex-M0+
Arduino YÚN - ATmega32U4
Arduino Uno - ATmega328P-PU Arduino Ethernet - ATmega328
Arduino Mega - ATmega 2560 Arduino Tian - Atheros AR9342
Arduino Nano - ATmega328P-AU Arduino Industrial 101 - Atheros AR9331
Arduino Leonardo - ATmega32u4 Arduino Leonardo ETH - ATmega32u4
Arduino 101 - Intel Curie Arduino MKR WAM 1300 - SAMD21 Cortex-M0+
Arduino Micro - ATmega32U4 Arduino MKR GSM 1400 - SAMD21 Cortex-M0+
Arduino Mini - ATmega328 Arduino Gemma - ATiny85
Arduino Zero - ATSAMD21G18 Arduino Lilypad Arduino USB - ATmega32u4
Arduino Due - AT91SAM3X8E Arduino Lilypad Arduino Main Board -
Arduino ADK - ATmega2560 ATmega168/ATmega328V
Arduino MO - ATSAMD21G18 Arduino Lilypad Arduino Simple - ATmega328P-AU
Arduino MO Pro - ATSAMD21G18 Arduino Lilypad Arduino Simple Snap - ATmega328P-AU
SKILL DEVELOPMENT PROGRAMME
PIN CONFIGURATION
• The Arduino Uno has 6 analog pins, which utilize ADC (Analog to Digital converter).
• These pins serve as analog inputs but can also function as digital inputs or digital
outputs.
Analog to Digital Conversion
• ADC stands for Analog to Digital Converter. ADC is an electronic circuit used to
convert analog signals into digital signals. This digital representation of analog signals
allows the processor (which is a digital device) to measure the analog signal and use it
through its operation.
• Arduino Pins A0-A5 are capable of reading analog voltages. On Arduino the ADC has
10-bit resolution, meaning it can represent analog voltage by 1,024 digital levels. The
ADC converts voltage into bits which the microprocessor can understand.
• One common example of an ADC is Voice over IP (VoIP)
Arduino Uno Pinout - Digital Pins
• On the Arduino, When the digital pins are configured as output, they are set to
0 or 5 volts. When the digital pins are configured as input, the voltage is
supplied from an external device. This voltage can vary between 0-5 volts
which is converted into digital representation (0 or 1). To determine this, there
are 2 thresholds:
● Below 0.8v - considered as 0.
● Above 2v - considered as 1.
SKILL DEVELOPMENT PROGRAMME
Arduino IDE
Open your
Arduino IDE
Start Succes
SPECIAL PIN FUNCTIONS
Each of the 14 digital pins and 6 Analog pins on the Uno can be used as an input
or output, using pinMode(),digitalWrite(), and digitalRead() functions.
long
Extended size data type for long integers, without decimal points, stored in 32 bit value with a
range of 2147483647 to -2147483648.
long variableName=90000;
Float
A data type for floating point numbers or numbers having decimal points. Floating point
numbers having greater resolution than integers and are stored as 32 bit value with a range of
3.4028235E+38 to -3.4028235E+38
float variableName=3.14;
Special Functions
pinMode()
Description
Configures the specified pin to behave either as an input or an output. See the Digital Pins
page for details on the functionality of the pins.
Syntax
pinMode(pin, mode);
Parameters
pin: the Arduino pin number to set the mode of.
mode: INPUT, OUTPUT
Reads the value from a specified digital pin, either HIGH or LOW.
Syntax
digitalRead(pin);
Parameters
pin: the Arduino pin number you want to read
Returns
HIGH or LOW
digitalWrite()
Description
Write a HIGH or a LOW value to a digital pin.
Example
void setup() {
pinMode(13, OUTPUT); // sets the digital pin 13 as output
}
void loop() {
digitalWrite(13, HIGH); // sets the digital pin 13 on
delay(1000);
}
analogRead()
Description
Reads the analog value from the specified analog pin (A0-A5)
Syntax
analogRead(pin);
Parameters
pin: the name of the analog input pin to read from (A0 to A5)
analogRead(A3);
analogWrite()
Description
• Writes an analog value (PWM wave) to a pin.
• Can be used to light a LED at varying brightnesses or drive a motor at various speeds.
Syntax
analogWrite(pin, value);
Description
Pauses the program for the amount of time (in milliseconds) specified as parameter. (There are 1000
milliseconds in a second.)
Syntax
delay(time that you want to delay in ms);
Eg:
delay(500);
Description
Pauses the program for the amount of time (in microseconds) specified as parameter.
Syntax
delayMicroseconds(time that you want to delay in ms)
Eg:
delay(500);
LED blinking
Start Succes
LED blinking
pinMode(LED_BUILTIN, OUTPUT);
Start Succes
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(LED_BUILTIN, LOW);
SKILL DEVELOPMENT PROGRAMME
LED blinking
Start Succes
SKILL DEVELOPMENT PROGRAMME
RGB LED
Start Succes
SKILL DEVELOPMENT PROGRAMME
LED blinking
Start Succes
SKILL DEVELOPMENT PROGRAMME
LED Array
Try it yourself…..
Start Succes
How many different patterns you can make…?
SKILL DEVELOPMENT PROGRAMME
Potentiometer
Start Succes
SKILL DEVELOPMENT PROGRAMME
Potentiometer
Start Succes
Circuit
Connect the anode (the longer, positive leg) of your LED to digital output pin 9 on your board through a 220 ohm
resistor. Connect the cathode (the shorter, negative leg) directly to ground.
• Pulse Width Modulation, or PWM, is a technique for getting analog results with digital means. Digital
control is used to create a square wave, a signal switched between on and off.
• This on-off pattern can simulate voltages in between the full Vcc of the board (e.g., 5 V on UNO, 3.3 V
on a MKR board) and off (0 Volts) by changing the portion of the time the signal spends on versus the
• The duration of "on time" is called the pulse width. To get varying analog values, you change, or
• If you repeat this on-off pattern fast enough with an LED for example, the result is as if the signal is a
steady voltage between 0 and Vcc controlling the brightness of the LED.
Code
After declaring pin 9 to be your ledPin, there is nothing to do in the setup() function of your code.
The analogWrite() function that you will be using in the main loop of your code requires two
arguments: One telling the function which pin to write to, and one indicating what PWM value to
write.
In order to fade your LED off and on, gradually increase your PWM value from 0 (all the way off) to
255 (all the way on), and then back to 0 once again to complete the cycle. In the sketch below, the
PWM value is set using a variable called brightness. Each time through the loop, it increases by the
value of the variable fadeAmount.
If brightness is at either extreme of its value (either 0 or 255), then fadeAmount is changed to its
negative. In other words, if fadeAmount is 5, then it is set to -5. If it's -5, then it's set to 5. The next
time through the loop, this change causes brightness to change direction as well.
analogWrite() can change the PWM value very fast, so the delay at the end of the sketch controls
the speed of the fade. Try changing the value of the delay and see how it changes the fading effect.
SKILL DEVELOPMENT PROGRAMME
Start Succes
SKILL DEVELOPMENT PROGRAMME
PIR Sensor
Start Succes
SKILL DEVELOPMENT PROGRAMME
PIR Sensor
Start Succes
SKILL DEVELOPMENT PROGRAMME
Buzzer
Start Succes
SKILL DEVELOPMENT PROGRAMME
Buzzer
Start Succes
SKILL DEVELOPMENT PROGRAMME
Intruder Detector
Ultrasonic Sensor
Start Succes
SKILL DEVELOPMENT PROGRAMME
Step 1 : Definition
#define echoPin 8
Ultrasonic Sensor #define trigPin 9
long duration;
int distance;
void setup(){
Serial.begin(9600);
pinMode(trigPin,OUTPUT);
pinMode(echoPin,INPUT);
}
SKILL DEVELOPMENT PROGRAMME
digitalWrite(trigPin, LOW);
Ultrasonic Sensor delayMicroseconds(2);
digitalWrite(trigpin,HIGH);
delayMicroseconds(10);
digitalWrite(trigpin,LOW);
distance=(duration*0.034/2);
duration=pulseIn(echoPin,HIGH);
Ultrasonic Sensor
distance=(duration*0.034/2);
distance=(duration*0.034/2);
duration=pulseIn(echoPin,HIGH);
Ultrasonic Sensor
distance=(duration*0.034/2);
Serial.print("Distance: ");
Serial.println(distance);
Serial.print(" cm ");
SKILL DEVELOPMENT PROGRAMME
IR Sensor Module
Start Succes
SKILL DEVELOPMENT PROGRAMME
Motor Driver
Start Succes
SKILL DEVELOPMENT PROGRAMME
Relay
Start Succes
SKILL DEVELOPMENT PROGRAMME
Relay
Start Succes
SKILL DEVELOPMENT PROGRAMME
LCD Display
Start Succes
SKILL DEVELOPMENT PROGRAMME
LCD Display
Start Succes
LCD Display Pin1(Vss):Ground pin of the LCD module.
Pin Description
Pin2(Vcc): Power to LCD module (+5V supply is given to this pin)
void setup() {
lcd.begin(16, 2);
Start lcd.print("hello, world!"); Succes
}
void loop() {
}
)
#include <LiquidCrystal.h>
void setup() {
lcd.begin(16, 2);
Start lcd.print("hello, world!"); Succes
}
void loop() {
}
LCD
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
Display Options void setup() {
lcd.begin(16, 2);
1. lcd.clear()
}
void loop() {
lcd.print("hello, world!");
Start delay(500); Succes
lcd.clear();
delay(500);
}
LCD #include <LiquidCrystal.h>
void setup()
2. lcd.home() {
lcd.begin(16, 2);
lcd.print("hello, world!");
}
Start Succes
void loop()
{
lcd.home();
lcd.print("XXX");
}
LCD #include <LiquidCrystal.h>
void setup() {
3. lcd.setCursor() lcd.begin(16, 2);
lcd.setCursor(2, 1);
lcd.print("hello, world!");
}
Start Succes
void loop() {
}
LCD #include <LiquidCrystal.h>
Display Options
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
lcd.begin(16, 2);
7. lcd.scrollDisplayLeft() lcd.print("hello, world!");
}
Start Succes
void loop() {
lcd.scrollDisplayLeft();
delay(1000);
}
LCD #include <LiquidCrystal.h>
void setup() {
lcd.begin(16, 2);
8. lcd.autoscroll() }
void loop() {
Start Succes
lcd.setCursor(0, 0);
lcd.autoscroll();
lcd.print("ABC");
delay(500);
}
The circuit is so simple and small , there is only few connection to be made
Start Succes
App Inventor
Block editor
Start Succes
SKILL DEVELOPMENT PROGRAMME
App Inventor
Block editor
Start Succes
SKILL DEVELOPMENT PROGRAMME
Start Succes
Robotics: Robots are playing a major role in manufacturing industries for assembling,
Transportation etc. Hence one should use Arduino if he/she is planning to make a
prototype in these areas.
Monitoring Devices: There are several applications in mechanical engineering exists,
where we need to monitor any parameters via sensors like Temperature of coils, Fluid
levels, Pressure etc, In that case Arduino comes into play. Similarly, in several projects
like automatic vending machines, bar cutting and feeding machines Arduino can be
programmed to control the pneumatic motions or valves etc.
Aero-modelling/ UAV applications: Arduino can be used in UAV aircrafts or drones for
several control and measurement applications.
Thermal / Refrigeration: Automatic control panels of Thermal / Refrigeration units can
be programmed by using Arduino for applications such as Heat exchanger temperature
monitoring, Refrigeration parameter monitoring etc.