100% found this document useful (1 vote)
251 views

Basic Arduino Workshop

This document outlines an Arduino workshop conducted by Yogi Hamdani. The workshop covers an introduction to Arduino boards and microcontrollers, Arduino programming using the IDE, and a hands-on system development exercise to build a reverse parking sensor system. Key topics covered include different Arduino boards, analog and digital input/output, programming basics like loops and conditional statements, and using sensors and actuators like a ping sensor, buzzer and LEDs.

Uploaded by

A Fahrul Aji
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
251 views

Basic Arduino Workshop

This document outlines an Arduino workshop conducted by Yogi Hamdani. The workshop covers an introduction to Arduino boards and microcontrollers, Arduino programming using the IDE, and a hands-on system development exercise to build a reverse parking sensor system. Key topics covered include different Arduino boards, analog and digital input/output, programming basics like loops and conditional statements, and using sensors and actuators like a ping sensor, buzzer and LEDs.

Uploaded by

A Fahrul Aji
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

BASIC ARDUINO

WORKSHOP

By :
Yogi Hamdani S.T., B.Eng.
[email protected]

Workshop Content
Introduction to Arduino
Arduino Programming (hands-on)
System Development

3/10/2016

BASIC ARDUINO WORKSHOP - YOGI HAMDANI

INTRODUCTION TO
ARDUINO

What is Arduino?
Microcontroller board contains on board
power supply, USB port to communicate with
PC, and microcontroller chip.
Open source hardware
INPUT FROM
SENSORS

3/10/2016

PROCESSING IN
MICROCONTROLLER

BASIC ARDUINO WORKSHOP - YOGI HAMDANI

OUTPUT TO
ACTUATORS

Arduino Boards

3/10/2016

BASIC ARDUINO WORKSHOP - YOGI HAMDANI

Arduino Mega
54 digital input/output pins
(of which 14 can be used as PWM outputs)
16 analog inputs
USB connection

3/10/2016

BASIC ARDUINO WORKSHOP - YOGI HAMDANI

Analog / Digital
All physical quantities are analog.
Analog quantity takes any value between its
minimum and maximum value.
(in Arduino 0-255 / 8 bits)
Digital quantity takes specific levels of value
with specific offset / on-off condition.
(in Arduino 0-1)

3/10/2016

BASIC ARDUINO WORKSHOP - YOGI HAMDANI

ARDUINO
PROGRAMMING

Program Download
http://arduino.cc/en/Main/Software

Programming Platform
Integrated
Development
Environment (IDE)
C language
programming

3/10/2016

BASIC ARDUINO WORKSHOP - YOGI HAMDANI

Sample Program (Built-In LED)


1. Open Arduino IDE
2. Click File ->
Examples ->
01.Basics ->
Blink

3/10/2016

BASIC ARDUINO WORKSHOP - YOGI HAMDANI

10

Program Structure
3/10/2016

BASIC ARDUINO WORKSHOP - YOGI HAMDANI

11

Program Structure
3/10/2016

BASIC ARDUINO WORKSHOP - YOGI HAMDANI

12

Program Structure
3/10/2016

BASIC ARDUINO WORKSHOP - YOGI HAMDANI

13

Upload Program
1. Check Connection
Click Tool ->
Select Board,
Select Port
Check on bottom
2. Click Upload

3/10/2016

BASIC ARDUINO WORKSHOP - YOGI HAMDANI

14

Basic Syntax Digital I/O


1. pinMode(x,OUTPUT); for pin x as output
pinMode(y,INPUT); for pin y as input
2. digitalWrite(x,HIGH); set pin x to ON (1)
digitalWrite(x,LOW); set pin x to OFF (0)
3. digitalRead(y); read pin y status
4. delay(z); set delay for z ms

3/10/2016

BASIC ARDUINO WORKSHOP - YOGI HAMDANI

15

Data Types and Statement

Integer: declare variable as integer.


example: int x = 10;
Floating Point: declare variable as numbers .
example: float x = 10.50;
Character: declare variable as single character.
example: char z = y;
String: declare variable as multiple characters.
example: String z = xyz;

3/10/2016

BASIC ARDUINO WORKSHOP - YOGI HAMDANI

16

Operators
Math Operators: (+,-,*,/,%,^)
example:
int x = 5;
int y = 7;
int z = x + y;

Logic Operators: (==, !=, &&, ||)


Comparison Operators: (<,>,<=,>=)

3/10/2016

BASIC ARDUINO WORKSHOP - YOGI HAMDANI

17

IF Statement
Example 1:
if(condition 1)
{
do something;
}

3/10/2016

Example 2:
if(condition 1)
{
do something;
}
else
{
do something;
}

BASIC ARDUINO WORKSHOP - YOGI HAMDANI

Example 3:
if(condition 1)
{
do something;
}
else if(condition 2)
{
do something;
}
else
{
do something;
}
18

Loop Statement
For
example:
for(int i=0; i<x; i++)
{
do something;
}

3/10/2016

While
example:
while(condition)
{
do something;
}

BASIC ARDUINO WORKSHOP - YOGI HAMDANI

Do while
example:
do
{
do something;
}
while(condition)

19

Serial Monitor

3/10/2016

BASIC ARDUINO WORKSHOP - YOGI HAMDANI

20

Exercise
Turn LED ON when switch is pressed.
Print status to serial monitor.

Ground Pin
Digital Pin

3/10/2016

BASIC ARDUINO WORKSHOP - YOGI HAMDANI

21

Wiring

3/10/2016

BASIC ARDUINO WORKSHOP - YOGI HAMDANI

22

Programming
3/10/2016

BASIC ARDUINO WORKSHOP - YOGI HAMDANI

23

Program Code
int LED = 12;
int Switch = 8;
void setup()
{
Serial.begin(9600);
pinMode(LED,OUTPUT);
pinMode(Switch,INPUT);
}

3/10/2016

void loop()
{
digitalWrite(LED,LOW);
if(digitalRead(Switch) == HIGH)
{
Serial.println("ON");
digitalWrite(LED,HIGH);
}
Serial.println("OFF");
delay(500);
}

BASIC ARDUINO WORKSHOP - YOGI HAMDANI

24

Questions ???

SYSTEM DEVELOPMENT
(Reverse Parking Sensor System)

How it works?
1. Sensors are activated and sense the distance.
2. Controller process the data.
3. Notify driver with buzzer / LED.

3/10/2016

BASIC ARDUINO WORKSHOP - YOGI HAMDANI

27

Equipments
INPUT:
- Switch
- Ping Sensor

3/10/2016

OUTPUT:
- Buzzer
- LED

BASIC ARDUINO WORKSHOP - YOGI HAMDANI

28

Input Analysis
1. System is activated by switch.
2. Ping sensor send ultrasonic wave via trigger pin.
3. If hit an object, the reflected wave may be received
through echo pin.

3/10/2016

BASIC ARDUINO WORKSHOP - YOGI HAMDANI

29

Ping Sensor

3/10/2016

BASIC ARDUINO WORKSHOP - YOGI HAMDANI

30

Input Analysis
4. Ping sensor gives time duration (in s) between
transmission and receiving reflected wave.
5. Analyze time duration into distance measurement.

3/10/2016

BASIC ARDUINO WORKSHOP - YOGI HAMDANI

31

pulseIn Function
int echo = 8
int time_duration;
void setup()
{
pinMode(echo, INPUT);
}
void loop()
{
time_duration = pulseIn(echo, HIGH);
}

3/10/2016

BASIC ARDUINO WORKSHOP - YOGI HAMDANI

32

Output Requirement
1. Buzzer rings more intense as distance is closer.
2. LED blinks / turns on longer as distance is closer.
3. Give information about distance via serial monitor.
Distance Left
>= 20 cm

Buzzer
Not Ring

>= 15 cm && < 20 cm


>= 10 cm && < 15 cm
>= 5 cm && < 10 cm
< 5 cm

Ring A
Ring B
Ring C
Ring D

3/10/2016

BASIC ARDUINO WORKSHOP - YOGI HAMDANI

LED Blue LED Red


ON
OFF

ON
ON
ON
ON

Blink
Blink
ON
ON
33

PROGRAMMING
PLAY TIME

You might also like