getting started with arduino workshop

31
Getting started with Arduino Hands-on Workshop Sudar Muthu http://hardwarefun.com @hardwarefun

Upload: sudar-muthu

Post on 28-Jan-2015

121 views

Category:

Technology


7 download

DESCRIPTION

Slides from my "Getting started with Arduino" workshop. Details at http://hardwarefun.com/news/slides-from-getting-started-with-arduino-workshop

TRANSCRIPT

Page 1: Getting started with arduino workshop

Getting started with ArduinoHands-on Workshop

Sudar Muthuhttp://hardwarefun.com

@hardwarefun

Page 2: Getting started with arduino workshop

What is an Arduino?

Photo credit: Arduino team

Page 3: Getting started with arduino workshop

Types of Arduino

• Leonardo, Uno (and older ones)• Yun (Includes a Linux Kernel)• Due (32-bit)• Mega (more input pins)• Arduino BT (includes Bluetooth)• LilyPad (wearable)• Arduino Pro• ADK (supports Android ADK)• Clones (around 300+)

Page 4: Getting started with arduino workshop

Arduino Shields

http://shieldlist.org/

Page 5: Getting started with arduino workshop

http://hardwarefun.com 5

Breadboard Basics

Page 6: Getting started with arduino workshop

http://hardwarefun.com 6

• The first two and the last two rows are connected

• In all the other rows, columns are connected• Connect the first and last row to power• Connect the second and second last row to

ground

How to use a breadboard

Page 7: Getting started with arduino workshop

http://hardwarefun.com 7

Powering Up Arduino

Page 8: Getting started with arduino workshop

http://hardwarefun.com 8

• Using USB cable• Using DC power jacket• Giving voltage directly into Vin pin• Giving regulated voltage directly into 5V pin

Different ways to power up Arduino

Page 9: Getting started with arduino workshop

http://hardwarefun.com 9

Setting Up Arduino

Page 10: Getting started with arduino workshop

http://hardwarefun.com 10

Testing The Setup With A “Hello World” Program

Page 11: Getting started with arduino workshop

http://hardwarefun.com 11

Blinking LED

Page 12: Getting started with arduino workshop

http://hardwarefun.com 12

• Insert a LED in pin 13• Open File->Examples->Basics->Blink• Select Tools->Boards->Arduino Uno• Select File->Upload (or press ctrl+u)• You should get the message “Done upload”• Your Led should blink• Congrats you can program Arduino now

Making a LED blink

Page 13: Getting started with arduino workshop

http://hardwarefun.com 13

Anatomy Of An Arduino Sketch

Page 14: Getting started with arduino workshop

Things you can try

• Vary the frequency at which the LED is blinking

• Add more LED’s

Page 15: Getting started with arduino workshop

http://hardwarefun.com 15

• Uno has one UART hardware port, using which we can exchange information with computer

• Very useful for debugging• Works at a specified baud rate• Use Serial Monitor to read values (Tools ->

Serial Monitor)• SoftwareSerial is also available

Printing values through Serial

Page 16: Getting started with arduino workshop

Reading values from Serial

serial.read()serial.print()

serial.println()

https://github.com/sudar/arduino-sketches/blob/master/SerialPrint/SerialPrint.ino

Page 17: Getting started with arduino workshop

http://hardwarefun.com 17

Digital Input And Output

Page 18: Getting started with arduino workshop

http://hardwarefun.com 18

Digital Input

Page 19: Getting started with arduino workshop

Code

Open File->Examples->Basics->DigitalReadSerial

Page 20: Getting started with arduino workshop

http://hardwarefun.com 20

The LED blink that we did at “setting up Arduino” is Digital output

Digital Output

Page 21: Getting started with arduino workshop

http://hardwarefun.com 21

Analog Input

Page 22: Getting started with arduino workshop

http://hardwarefun.com 22

• Connect the LDR on pin A0 and Gnd• LDR’s resistance varies based on the amount

of light present• Read the current value using analogRead()• Print the value in Serial Monitor

Reading Analog values from sensors

Page 23: Getting started with arduino workshop

Code

Open File->Examples->Basics->AnalogReadSerial

Page 24: Getting started with arduino workshop

http://hardwarefun.com 24

Analog Output

Page 25: Getting started with arduino workshop

http://hardwarefun.com 25

• What is PWM?• Analog like behavior using digital output• Works by switching the LED on and off

regularly• Changing the brightness of a Led

Analog Output

Page 26: Getting started with arduino workshop

Code

Open File->Examples->Analog->Fading

Page 27: Getting started with arduino workshop

http://hardwarefun.com 27

Combining Input and Output

Page 28: Getting started with arduino workshop

Control an LED based on lightvoid setup(){ pinMode(13, OUTPUT);}

void loop(){ int val = analogRead(A0); if (val > 50) { digitalWrite(13, HIGH); } else { digitalWrite(13, LOW); }}

Page 29: Getting started with arduino workshop

Things to try

• Control LED based on button press• Alternate two LED’s based on button press• Persist the status of button

Page 30: Getting started with arduino workshop

Moving Forward

• Connect to display devices like 7-segment display or LCD

• Connect to motion sensors• Connect to other components like shift

register etc• Connect to a RTC chip

Page 31: Getting started with arduino workshop

Things which I have tried• Connecting to mobile Android phones using

– Bluetooth– Wired and wireless– Audio Jacket– NFC– ADK

• Connected all sorts of display devices including VGA devices like projectors• Connected external USB devices like keyboard, mouse and even USB Missile launchers -

http://hardwarefun.com/tutorials/controlling-usb-missile-launchers-using-arduino• Connected ez430 chronos watch• Connected IR devices like TV Remotes etc• Connected bluetooth devices like WiiRemote• Created small autonomous bots that can be controlled by either a WiiRemote or Android

phones - http://hardwarefun.com/projects/asimi• Detect motion using PIR, IR and ultrasound motion sensors• More projects at http://hardwarefun.com