44
Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca http://arduino.cc/ http://home.techwiz.ca/~peters/presentations/ArduinoIntro/ This presentation is licensed under Creative Common Attribution-ShareAlike 4.0 International http://creativecommons.org/licenses/by-sa/4.0/

Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

  • Upload
    others

  • View
    6

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

Arduino Intro

Introduction to ArduinoFor linux geeks

By Peter Sjöbergpeters-oclug at techwiz point ca

http://arduino.cc/

http://home.techwiz.ca/~peters/presentations/ArduinoIntro/

This presentation is licensed under Creative Common Attribution-ShareAlike 4.0 International http://creativecommons.org/licenses/by-sa/4.0/

Page 2: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

2

Show of hands - how many people

- know what raspberry pi is ?

- know what arduino is ?

- have interest in small electronics projects, knows what spi/i2c/3wire or xbee is?

- want to know more about arduino?

Disclaimer to Arduino SMEs, this is an intro so I skipping things/don't tell the whole truth in the name of KISS.

Page 3: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

3

What is Arduino?

● The Arduino platform/framework is a tool for making computers that can sense and control more of the physical world than your desktop computer.

● It's a small computer that can interact with the world around it.

● Arduino can be used to develop interactive objects, taking inputs from a variety of switches or sensors, and controlling a variety of lights, motors, and other physical outputs.

● Arduino projects can be stand-alone, or they can communicate with software running on your computer

Page 4: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

4

What is Arduino - cont

● Open hardware

– Schematics available

– Creative Commons Attribution Share-Alike license● Open source

– Bootloader, ide, libraries all open● Simple to use

– Very easy to get going● Popular

– Big community support– Lots of software and hardware available

Page 5: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

5

What is Arduino

● A small cheap micro controller● Basic “uno” model comes with

● 16MHz cpu● 32K Flash (for program)● 2K Ram (variables)● 1K EEProm● 14 I/O pins● 6 Analog input pins

● Single program/task● Only storage is eeprom

Page 6: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

6

What Arduino is NOT

● Not multitasking OS

● Not multiuser OS

● Not any kind of Operating System at all

● Not blazing fast

● Not that powerful, 2K ram does limit things.

● Not a storage device, 1K EEProm doesn't allow much to be stored

● Not vulnerable to the BASH shellshock bug

Page 7: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

7

Arduino vs Rasberry PiArduino

● Real time, <5uSec response to changes, bit banging in usec range can be done.

● Single task, type “delay(1000)” in the program and it will do nothing at all for 1 second.

● Low Power, a battery can last for way more then a few hours(days to year on 2*AA!).

Raspberry Pi/BBB● Multitasking OS makes millisec

response a challenge and forget bitbanging in uSec range.

● Multitasking, reading a webcam while running ssh, webserver, mail and a database “independent” of each other is ok

● External power required for anything more than a few hours

Page 8: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

8

How does it work?

● Arduino is a MicroController Unit or MCU● It does not have an operating system running.● It's a single program that starts when the power

comes on and then just keeps running● It does have interrupt that can be used to react

fast on pin changes or kick off functions on a schedule.

Page 9: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

9

What can it do ?

● It has digital Input Output and Analog input pins to interact with the outside world

● With the I/O pins it can read sensors and send information or (de)activate external hardware

● For example it can read acceleration/gravity/magnetic sensors and control motors in a quadrocopter based on that info.

Page 10: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

10

What elseWhat else

● The basic hardware can be extended with shields and The basic hardware can be extended with shields and sensors, so what can you imagine?sensors, so what can you imagine?

● Shields Shields http://shieldlist.org/http://shieldlist.org/ : :– Ethernet+sd card(=storage)Ethernet+sd card(=storage)

– WirelessWireless

– GpsGps

– stepper and/or dc motorstepper and/or dc motor

– Music/mp3/voicMusic/mp3/voic

– CAN-bus(car)CAN-bus(car)

And hundreds moreAnd hundreds more

Page 11: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

11

What else - cont

– VibrationVibration

– AngleAngle

– MagneticMagnetic

– CapacitiveCapacitive

– 3 color sensor3 color sensor

– RFIDRFID

– JoystickJoystick

– Infra redInfra red

– FlameFlame

● SensorsSensors– LightLight– TemperatureTemperature– HumidityHumidity– DistanceDistance– HeartbeatHeartbeat– MotionMotion– SoundSound– GasGas

Page 12: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

12

What can it be used for?

● 3D Printer● CNC machine● Plant watering● Energy monitoring● Animated halloween/christmas decorations● Home automation● Quadrocopter● Robot● Automotive applications● Plotter● Door lock security● Weather station

● Coffee making control● Propeller clock● Disco light● Led sign● Alarm clock● Gas detector● Drawing robot● Music instruments● Bike finder (gps+gsm)● IR Remote replacement● Garage door monitor● Games

The usage cases is a very very long list but to give you a few examples, more at http://playground.arduino.cc/Projects/Ideas (and google of course)

Page 13: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

13

How to get started

● To get started you need– 1 Arduino, cheap ($10-15) clones can be found on

Ebay.

– 1 Linux computer (I have heard that legacy OS like M$ Windoze or macintoy also works)

– Arduino IDE● Install instructions at

http://playground.arduino.cc/Learning/Linux

Page 14: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

14

Install software

● Fedora: – sudo yum install arduino

● Ubuntu:– sudo apt-get install arduino

● No USB drivers hunt needed

Page 15: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

15

Starting Arduino IDE

Page 16: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

16

Hello World

● Since it's no screen, the mandatory “Hello World” for arduino is normally a program called “Blinky”

● It makes a built in LED blink and with that it's making itself known to the world

● It's one of the example programs included with Arduino IDE

Page 17: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

17

// The mandatory “Hello world” program for Arduino// It makes the built in LED blink

// Initialize the environmentvoid setup(){ pinMode(LED_BUILTIN,OUTPUT); // Set the LED pin to output mode}

// Work loopvoid loop(){ digitalWrite(LED_BUILTIN,HIGH); // Turn ON the LED delay(1000); // Wait 1000ms=1 second digitalWrite(LED_BUILTIN,LOW); // Turn OFF the LED delay(1000); // Wait 1000ms=1 second}

Page 18: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

18

Arduino running blinky

Page 19: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

19

Arduino models

● Arduino comes in several models to suit different needs

● Arduino UNO is the reference model● Other models comes with different voltage, io

pin count, custom shapes like the flexible lilypad and so on

● http://arduino.cc/en/Main/Products

Page 20: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

20

Arduino software

● Besides basic c(++) programming it is a lot of libraries for misc functions.

● Libraries does simplify things when it comes to interact with external (and internal) parts

● For example, the time library that creates some variables that keeps time (Y-M-D h:m:s) and if you have a GPS or RTC module added you can get the true time without having to somehow set it each time you start up the arduino.

● Official list at http://playground.arduino.cc/Main/LibraryList● Unofficial list - try google

Page 21: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

21

Demo time

You've seen blinky, now what would you be interested in being created right here ?

● Reaction time game● Temp sensor● RFID tag reader● 7SEG display clock● Stepper motor● Ultra sound distance sensor● Other● Had enough – skip to QA and do demo in BoF breakout

Page 22: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

22

Q & A

● Questions

● Primary URL: http://arduino.cc/ (note .cc not .com)

● Local arduino group, start with http://inventorartist.com/learn-arduino/

● For more, google “arduino”

● This presentation http://home.techwiz.ca/~peters/presentations/ArduinoIntro/

● Wikipedia entry: http://en.wikipedia.org/wiki/Arduino

● For more, google “arduino”

Page 23: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

Arduino Intro October 2,2014

Copyright by Peter Sjöberg, license Creative Common Attribution-ShareAlike

1

Arduino Intro

Introduction to ArduinoFor linux geeks

By Peter Sjöbergpeters-oclug at techwiz point ca

http://arduino.cc/

http://home.techwiz.ca/~peters/presentations/ArduinoIntro/

This presentation is licensed under Creative Common Attribution-ShareAlike 4.0 International http://creativecommons.org/licenses/by-sa/4.0/

Page 24: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

Arduino Intro October 2,2014

Copyright by Peter Sjöberg, license Creative Common Attribution-ShareAlike

2

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

2

Show of hands - how many people

- know what raspberry pi is ?

- know what arduino is ?

- have interest in small electronics projects, knows what spi/i2c/3wire or xbee is?

- want to know more about arduino?

Disclaimer to Arduino SMEs, this is an intro so I skipping things/don't tell the whole truth in the name of KISS.

Page 25: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

Arduino Intro October 2,2014

Copyright by Peter Sjöberg, license Creative Common Attribution-ShareAlike

3

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

3

What is Arduino?

● The Arduino platform/framework is a tool for making computers that can sense and control more of the physical world than your desktop computer.

● It's a small computer that can interact with the world around it.

● Arduino can be used to develop interactive objects, taking inputs from a variety of switches or sensors, and controlling a variety of lights, motors, and other physical outputs.

● Arduino projects can be stand-alone, or they can communicate with software running on your computer

This text comes from http://arduino.cc/en/Guide/Introduction

Page 26: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

Arduino Intro October 2,2014

Copyright by Peter Sjöberg, license Creative Common Attribution-ShareAlike

4

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

4

What is Arduino - cont

● Open hardware

– Schematics available– Creative Commons Attribution Share-Alike license

● Open source

– Bootloader, ide, libraries all open● Simple to use

– Very easy to get going● Popular

– Big community support– Lots of software and hardware available

Page 27: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

Arduino Intro October 2,2014

Copyright by Peter Sjöberg, license Creative Common Attribution-ShareAlike

5

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

5

What is Arduino

● A small cheap micro controller● Basic “uno” model comes with

● 16MHz cpu● 32K Flash (for program)● 2K Ram (variables)● 1K EEProm● 14 I/O pins● 6 Analog input pins

● Single program/task● Only storage is eeprom

Arduino is a single-board microcontroller, intended to make building interactive objects or environments more accessible. The hardware consists of an open-source hardware board designed around an 8-bit Atmel AVR microcontroller, or a 32-bit Atmel ARM.

The top and bottom lines of connections are the power and io poins and the layout makes it possible to easily stack shields (add on boards) on top of it.

On the picture is two models, the the UNO which is the reference model and below is the pro mini which is as small as it gets unless you build your own.

Page 28: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

Arduino Intro October 2,2014

Copyright by Peter Sjöberg, license Creative Common Attribution-ShareAlike

6

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

6

What Arduino is NOT

● Not multitasking OS

● Not multiuser OS

● Not any kind of Operating System at all

● Not blazing fast

● Not that powerful, 2K ram does limit things.

● Not a storage device, 1K EEProm doesn't allow much to be stored

● Not vulnerable to the BASH shellshock bug

It's a 8bit cpu that has limited onboard resources. Some can be expanded like more eeprom or io ports but it may be easier to get a different model like the atmega1260 or 32bit arm (arduino due) if you need a more advanced program.

Page 29: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

Arduino Intro October 2,2014

Copyright by Peter Sjöberg, license Creative Common Attribution-ShareAlike

7

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

7

Arduino vs Rasberry PiArduino

● Real time, <5uSec response to changes, bit banging in usec range can be done.

● Single task, type “delay(1000)” in the program and it will do nothing at all for 1 second.

● Low Power, a battery can last for way more then a few hours(days to year on 2*AA!).

Raspberry Pi/BBB● Multitasking OS makes millisec

response a challenge and forget bitbanging in uSec range.

● Multitasking, reading a webcam while running ssh, webserver, mail and a database “independent” of each other is ok

● External power required for anything more than a few hours

“Bitbanging” is when you in your code manipulate a pin to generate a signal/receive a signal. For example for each byte for each bit If 0 then pin high;sleep 250;pin low;sleep 750 # usec to sleep Else pin high;sleep 750;pin low;sleep 250Ok with arduino, forget it with rpi since there the os multitasking kicks in and mess up the timing.

The Atmega datasheet states it is possible to go as low as 1uA with nothing on and safeguards off.With just simple programming trix (jeelib) you can easily get a pro-mini to sleep at <4mA (desolder the power led and you drop ~2mA more) and after that it just depends on how often you check your sensor.If you then run your project of 2xAA Ultimate Lithium batteries=3V and 3000mAh 2mAh means 2 months.Follow some of the trix from internet and you can get closer to 1uA and a year or two on 2 batteries.

https://www.sparkfun.com/tutorials/309

http://hwstartup.wordpress.com/2013/04/15/how-to-run-an-arduino-clone-on-aa-batteries-for-over-a-year-part-2/

Page 30: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

Arduino Intro October 2,2014

Copyright by Peter Sjöberg, license Creative Common Attribution-ShareAlike

8

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

8

How does it work?

● Arduino is a MicroController Unit or MCU● It does not have an operating system running.● It's a single program that starts when the power

comes on and then just keeps running● It does have interrupt that can be used to react

fast on pin changes or kick off functions on a schedule.

By default it does have some interrupts running to increase counters for milli/micro seconds and handle “delay” and (if used) pulse width modulation (PWM) but they are background tasks that you could disable and still run your program as long as you handle things like delay in your code.

Page 31: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

Arduino Intro October 2,2014

Copyright by Peter Sjöberg, license Creative Common Attribution-ShareAlike

9

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

9

What can it do ?

● It has digital Input Output and Analog input pins to interact with the outside world

● With the I/O pins it can read sensors and send information or (de)activate external hardware

● For example it can read acceleration/gravity/magnetic sensors and control motors in a quadrocopter based on that info.

Page 32: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

Arduino Intro October 2,2014

Copyright by Peter Sjöberg, license Creative Common Attribution-ShareAlike

10

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

10

What elseWhat else

● The basic hardware can be extended with shields and The basic hardware can be extended with shields and sensors, so what can you imagine?sensors, so what can you imagine?

● Shields Shields http://shieldlist.org/http://shieldlist.org/ : :– Ethernet+sd card(=storage)Ethernet+sd card(=storage)

– WirelessWireless

– GpsGps

– stepper and/or dc motorstepper and/or dc motor

– Music/mp3/voicMusic/mp3/voic

– CAN-bus(car)CAN-bus(car)

And hundreds moreAnd hundreds more

Page 33: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

Arduino Intro October 2,2014

Copyright by Peter Sjöberg, license Creative Common Attribution-ShareAlike

11

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

11

What else - cont

– VibrationVibration

– AngleAngle

– MagneticMagnetic

– CapacitiveCapacitive

– 3 color sensor3 color sensor

– RFIDRFID

– JoystickJoystick

– Infra redInfra red

– FlameFlame

● SensorsSensors– LightLight– TemperatureTemperature– HumidityHumidity– DistanceDistance– HeartbeatHeartbeat– MotionMotion– SoundSound– GasGas

Page 34: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

Arduino Intro October 2,2014

Copyright by Peter Sjöberg, license Creative Common Attribution-ShareAlike

12

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

12

What can it be used for?

● 3D Printer● CNC machine● Plant watering● Energy monitoring● Animated halloween/christmas decorations● Home automation● Quadrocopter● Robot● Automotive applications● Plotter● Door lock security● Weather station

● Coffee making control● Propeller clock● Disco light● Led sign● Alarm clock● Gas detector● Drawing robot● Music instruments● Bike finder (gps+gsm)● IR Remote replacement● Garage door monitor● Games

The usage cases is a very very long list but to give you a few examples, more at http://playground.arduino.cc/Projects/Ideas (and google of course)

Page 35: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

Arduino Intro October 2,2014

Copyright by Peter Sjöberg, license Creative Common Attribution-ShareAlike

13

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

13

How to get started

● To get started you need– 1 Arduino, cheap ($10-15) clones can be found on

Ebay.

– 1 Linux computer (I have heard that legacy OS like M$ Windoze or macintoy also works)

– Arduino IDE● Install instructions at

http://playground.arduino.cc/Learning/Linux

Arduino uno clone at ebay - <$10Ardunio pro mini (no usb) <$3Arduino micro (has usb) <$8Arduino mega1280/2560 clone - ~$15-$20

Page 36: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

Arduino Intro October 2,2014

Copyright by Peter Sjöberg, license Creative Common Attribution-ShareAlike

14

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

14

Install software

● Fedora: – sudo yum install arduino

● Ubuntu:– sudo apt-get install arduino

● No USB drivers hunt needed

To see if os can see the arduino: tail -f /var/log/messagesand plug in arduinoTo get software: go to http://arduino.cc/ -> Learning -> Getting started -> Linux http://www.arduino.cc/playground/Learning/Linux

Page 37: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

Arduino Intro October 2,2014

Copyright by Peter Sjöberg, license Creative Common Attribution-ShareAlike

15

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

15

Starting Arduino IDE

The Arduino IDE isn't that exciting but it does contain a few functions and a edit window.

Page 38: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

Arduino Intro October 2,2014

Copyright by Peter Sjöberg, license Creative Common Attribution-ShareAlike

16

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

16

Hello World

● Since it's no screen, the mandatory “Hello World” for arduino is normally a program called “Blinky”

● It makes a built in LED blink and with that it's making itself known to the world

● It's one of the example programs included with Arduino IDE

Page 39: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

Arduino Intro October 2,2014

Copyright by Peter Sjöberg, license Creative Common Attribution-ShareAlike

17

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

17

// The mandatory “Hello world” program for Arduino// It makes the built in LED blink

// Initialize the environmentvoid setup(){ pinMode(LED_BUILTIN,OUTPUT); // Set the LED pin to output mode}

// Work loopvoid loop(){ digitalWrite(LED_BUILTIN,HIGH); // Turn ON the LED delay(1000); // Wait 1000ms=1 second digitalWrite(LED_BUILTIN,LOW); // Turn OFF the LED delay(1000); // Wait 1000ms=1 second}

Page 40: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

Arduino Intro October 2,2014

Copyright by Peter Sjöberg, license Creative Common Attribution-ShareAlike

18

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

18

Arduino running blinky

Page 41: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

Arduino Intro October 2,2014

Copyright by Peter Sjöberg, license Creative Common Attribution-ShareAlike

19

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

19

Arduino models

● Arduino comes in several models to suit different needs

● Arduino UNO is the reference model● Other models comes with different voltage, io

pin count, custom shapes like the flexible lilypad and so on

● http://arduino.cc/en/Main/Products

Besides the 20 official versions on arduino.cc it's also tons of copies. Since the platform is open companies makes a their own version and the only limitation is that they can't call it arduino so you find names like funduino.It is only 3 factories that are authorized to use the arduino logo but it's way more places using it.If you buy a “real” arduino on ebay it's a good chance its counterfit and while it probably works fine you now overpaid for a counterfit clone and your money did go to some china company instead of the Arduino project you thought you supported. http://blog.arduino.cc/2013/07/10/send-in-the-clones/

Page 42: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

Arduino Intro October 2,2014

Copyright by Peter Sjöberg, license Creative Common Attribution-ShareAlike

20

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

20

Arduino software

● Besides basic c(++) programming it is a lot of libraries for misc functions.

● Libraries does simplify things when it comes to interact with external (and internal) parts

● For example, the time library that creates some variables that keeps time (Y-M-D h:m:s) and if you have a GPS or RTC module added you can get the true time without having to somehow set it each time you start up the arduino.

● Official list at http://playground.arduino.cc/Main/LibraryList● Unofficial list - try google

Page 43: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

Arduino Intro October 2,2014

Copyright by Peter Sjöberg, license Creative Common Attribution-ShareAlike

21

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

21

Demo time

You've seen blinky, now what would you be interested in being created right here ?

● Reaction time game● Temp sensor● RFID tag reader● 7SEG display clock● Stepper motor● Ultra sound distance sensor● Other● Had enough – skip to QA and do demo in BoF breakout

Page 44: Arduino Intro - Techwizpeters/presentations/ArduinoIntro/ArduinoI… · Arduino Intro Introduction to Arduino For linux geeks By Peter Sjöberg peters-oclug at techwiz point ca peters

Arduino Intro October 2,2014

Copyright by Peter Sjöberg, license Creative Common Attribution-ShareAlike

22

October 2,2014 Copyright Peter Sjöberg, license: Creative Common Attribution-ShareAlike

22

Q & A

● Questions

● Primary URL: http://arduino.cc/ (note .cc not .com)

● Local arduino group, start with http://inventorartist.com/learn-arduino/

● For more, google “arduino”

● This presentation http://home.techwiz.ca/~peters/presentations/ArduinoIntro/

● Wikipedia entry: http://en.wikipedia.org/wiki/Arduino

● For more, google “arduino”

.cc is coco islands but it's more because of .cc as in Creative Commons (and other TLDs like .org already taken)

Local interest group is changing around right now but look at http://inventorartist.com/learn-arduino/ for latest info.