Arduino workshop

38
innov8 BY – MAYUR KAGATHARA [email protected] Workshop On Arduino Basic Sensor interfacing Bluetooth (Android)

Transcript of Arduino workshop

Page 1: Arduino workshop

innov8

BY – MAYUR [email protected]

Workshop On Arduino• Basic• Sensor interfacing• Bluetooth (Android)

Page 2: Arduino workshop

What??

Page 3: Arduino workshop

Arduino Board“STRONG FRIEND” CREATED IN IVREA, ITALY

IN 2005 BY MASSIMO BANZI & DAVID CUARTIELLESOPEN SOURCE HARDWARE

PROCESSORCODING IS ACCESSIBLE & TRANSFERRABLE (C++, PROCESSING,

JAVA)

Page 4: Arduino workshop

Analog INPUTS

Digital I\OPWM(3, 5, 6, 9, 10,

11)

PWR IN USB (to Computer)

SCL\SDA(I2C Bus)

POWER 5V / 3.3V /

GND

RESET

Page 5: Arduino workshop

"UNO" means one in Italian and it is named to mark the release of Arduino software IDE 1.0The latest Arduino UNO R3 was released in 2011 and it is the third revision of UNO boards.

Specifications:

•Microcontroller : ATmega328p•Operating Voltage : 5V•Input Voltage (recommended) : 7-12V•Input Voltage (limits) : 6-20V•Digital I/O Pins : 14 (of which 6 provide PWM output)•Analog Input Pins : 6•DC Current per I/O Pin : 40 mA•DC Current for 3.3V Pin : 50 mA•Flash Memory : 32 KB (ATmega328) of which 0.5 KB used by bootloader SRAM 2 KB (ATmega328)•EEPROM : 1 KB (ATmega328)•Clock Speed : 16 MHZ

specifications

Page 6: Arduino workshop

Arduino IDE

CLANGUAGE

IDE =

Integrated

Development

Environment

Page 7: Arduino workshop

Why???

Page 8: Arduino workshop

Some uses of Arduino will

give the answer..

Page 9: Arduino workshop

5x5 LED Cube (Arduino Uno)

Page 10: Arduino workshop

Arduino Uno fan control 

Page 11: Arduino workshop

Obstacle Avoider Robot Using Arduino Uno And IR Proximity Sensor

Page 12: Arduino workshop

Ultrasonic distance meter with LCD display on Arduino UNO

Page 13: Arduino workshop

Automatic Fish Food Feeder using Arduino Uno 

Page 14: Arduino workshop

Connect a serial LCD to an Arduino UNO

Page 15: Arduino workshop

Room Temperature & Humidity Module using Arduino uno

Page 16: Arduino workshop

Save data of temperature and humidity on MySQL with Arduino Uno and Wifly

Page 17: Arduino workshop

I am not gonna show you more.

Discover it by yourself…

Trust me there are plenty of projects on Arduino.

Page 18: Arduino workshop

How???

Page 19: Arduino workshop

Adding control – let’s use the Arduinoand start programming!!!

Page 20: Arduino workshop

Concepts: INPUT vs. OUTPUTTHINK AS IF YOU ARE ARDUINO.

Inputs is a signal going into the board.

Output is any signal exiting from the board.

Page 21: Arduino workshop

Concepts: Analog vs. DigitalMicrocontrollers are digital devices – ON or OFF. Also called – discrete.analog signals are anything that can be a full range of values. What are some examples? More on this later…

5 V

0 V

5 V

0 V

Page 22: Arduino workshop

Arduino Integrated Development Environment (IDE)

Two required functions / methods / routines:

void setup(){

// runs once

}

void loop(){

// repeats

}

error & status messages

Page 23: Arduino workshop

Settings: Tools Serial Port

Your computer communicates to the Arduino microcontroller via a serial port through a USB-Serial adapter.

Check to make sure that the drivers are properly installed.

Page 24: Arduino workshop

Settings: Tools Board

Next, double-check that the proper board is selected under the ToolsBoard menu.

Page 25: Arduino workshop

Comments, Comments, Comments Comments are for you – the programmer and your friends…

or anyone else human that might read your code.

// this is for single line comments // it’s good to put a description at the // top and before anything ‘tricky’

/* this is for multi-line comments Like this… And this…. */

Page 26: Arduino workshop

comments

Page 27: Arduino workshop

BIG

7 C

ON

CEPT

S

digitalWrite(pin, HIGH/LOW)

analogWrite(pin, 0 to 255)

digitalRead(pin)

Serial.begin(9600);

analogRead(pin)

Serial.print(“Hello World”);

pinMode(pin, INPUT/OUTPUT)

Page 28: Arduino workshop

YO… You are now expert of Arduino…

I’m not kidding..

BORING PPT IS about to OVEROK let’s do some project..

Page 29: Arduino workshop

Compulsory things#include <library.h> //Require for some sensors.

void setup(){ Serial.begin(9600); //to communicate with board by computer pinMode(pin, INPUT/OUTPUT); }

void loop(){ PROGRAM THAT WILL RUN AND RUN AND RUN… delay(100);}

Page 30: Arduino workshop

Let’s get to coding…Project #1 – Blink

“Hello World” of Physical Computing

Pseudo-code – how should this work?

Turn LED ON Wait

Turn LED OFF

Wait Rinse & Repeat

Page 31: Arduino workshop

Three commands to know… pinMode(pin, INPUT/OUTPUT); ex: pinMode(13, OUTPUT);

digitalWrite(pin, HIGH/LOW); ex: digitalWrite(13, HIGH);

delay(time_ms); ex: delay(2500); // delay of 2.5 sec.

// NOTE: -> commands are CASE-sensitive

Page 32: Arduino workshop

Project #1: Wiring Diagram

Move the green wire from the power bus to pin 13 (or any other Digital I/O pin on the Arduino board.

Image created in Fritzing

Page 33: Arduino workshop

A few simple challengesLet’s make LED#13 blink!

Challenge 1a – blink with a 200 ms second interval.

Challenge 1b – blink to mimic a heartbeat

Challenge 1c – find the fastest blink that the human eye can still detect…

1 ms delay? 2 ms delay? 3 ms delay???

Page 34: Arduino workshop

Common program for digital sensor#include <library.h> //Require for some sensors.int a,void setup(){ Serial.begin(9600); pinMode(pin, INPUT);}

void loop(){ a = digitalRead(pin) Serial.println(a); delay(100);}

Page 35: Arduino workshop

Common program for analog sensor#include <library.h> //Require for some sensors.int a,void setup(){ Serial.begin(9600);

}

void loop(){ a = analogRead(pin) Serial.println(a); delay(100);}

Page 36: Arduino workshop

SoftwareSerial.h Library

SoftwareSerial NAME(Rx, Tx); //connect deviceRx= connect Tx of BluetoothTx = connect Rx of Bluetooth

NAME.begin(baudrate); // start communication

NAME.read(); //read from device

NAME.write(data); //write to device

Page 37: Arduino workshop

Common program for bluetooth#include <SoftwareSerial.h>SoftwareSerial mayur(10, 11); //common for uno, mega, leonardoint a;void setup(){ Serial.begin(9600); mayur.begin(9600);}void loop(){ a = mayur.read(pin) Serial.println(a); delay(100);}

Page 38: Arduino workshop

Thank you very much…

CONTACT me at:[email protected]