Movatterモバイル変換


[0]ホーム

URL:


Sudar Muthu, profile picture
Uploaded bySudar Muthu
PPTX, PDF8,202 views

Using arduino and raspberry pi for internet of things

The document introduces Arduino and Raspberry Pi for internet of things applications. It discusses the basics of both platforms, including components, programming, and interfacing with sensors and actuators. It provides examples of blinking LEDs, reading button input, and controlling an LED based on light level. Finally, it compares Arduino and Raspberry Pi, concluding they are best used together to take advantage of their complementary capabilities.

Related topics:

Embed presentation

Downloaded 421 times
Using Arduino and Raspberry Pi for Internet of Things Sudar Muthu (@sudarmuthu) http://hardwarefun.com/ http://github.com/sudar
Who am I?  Research Engineer by profession  I build robots as a hobby  Playing with Arduino for more than 4 years  Blogger about Arduino at http://hardwarefun.com  Moderator for Arduino India forum http://hardwarefun.com 2
Objective  Introduce Arduino  Introduce Raspberry Pi  Emphasis on IoT  See how both can be used for IoT http://hardwarefun.com 3
Arduino http://hardwarefun.com 4
What is Arduino?  Visual Basic for hardware  Includes both Hardware and software http://hardwarefun.com 5 Photo credit Arduino team
Different Arduino types  Arduino Uno (The one I am going to use today)  Arduino Mega  Arduino Due  Lillypad  Arduino BT  Arduino Ethernet  .. and clones http://hardwarefun.com 6
Getting to know the Arduino http://hardwarefun.com 7
Specs (Uno, Leonardo) Type Value Microcontroller ATmega328 Operating Voltage 5v Digital I/O Pins 14 (of which 6 provide PWM output) Analog Input Pins 6 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 http://hardwarefun.com 8
Identify these components in  Microcontroller  Power jacket  USB jacket  Digital pins  Analog pins  Reset button Arduino http://hardwarefun.com 9
Identify these components in Arduino  Voltage Regulator  Power Pins (how many are there?)  Ground Pins (how many are there?)  Vin Pin  Rx and Tx Pins  ICSP Headers http://hardwarefun.com 10
Identify these components in  Power Led  Rx and Tx Led’s  Test Led  Crystal  Anything else? Arduino http://hardwarefun.com 11
Powering up Arduino http://hardwarefun.com 12
Different ways to power up Arduino  Using USB cable  Using DC power jacket  Giving voltage directly into Vin pin  Giving regulated voltage directly into 5V pin http://hardwarefun.com 13
Setting up Arduino http://hardwarefun.com 14
Testing the setup with a “Hello World” program http://hardwarefun.com 15
Blinking LED http://hardwarefun.com 16
Making a LED blink  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  http://hardwarefun.com 17
People with electronics background Did I miss anything? http://hardwarefun.com 18
People with electronics background Did I miss anything? Hint: Ohm’s Law http://hardwarefun.com 19
Anatomy of an Arduino sketch http://hardwarefun.com 20
Printing values through Serial  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  SoftwareSerial is also available http://hardwarefun.com 21
Breadboard Basics http://hardwarefun.com 22
How to use a breadboard  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 http://hardwarefun.com 23
Digital Input and Output http://hardwarefun.com 24
Digital Input http://hardwarefun.com 25
Digital Output The LED blink that we did at “setting up Arduino” is Digital output http://hardwarefun.com 26
Analog Input http://hardwarefun.com 27
Reading Analog values from sensors  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 http://hardwarefun.com 28
Control an LED based on light void setup(){ pinMode(13, OUTPUT); } void loop(){ int val = analogRead(A0); if (val > 50) { digitalWrite(13, HIGH); } else { digitalWrite(13, LOW); } } http://hardwarefun.com 29
Analog Output http://hardwarefun.com 30
Analog Output  What is PWM?  Analog like behavior using digital output  Works by switching the LED on and off regularly  Changing the brightness of a Led http://hardwarefun.com 31
This is just the tip of an iceberg http://hardwarefun.com 32 There are tons of other features to Arduino which I have not talked about
Internet of Things http://hardwarefun.com 33
http://hardwarefun.com 34 "Internet of Things" by Wilgengebroed on Flickr
LoT is an overloaded term But I like this definition… “The Internet of Things is the interconnection of uniquely identifiable embedded computing devices within the existing Internet infrastructure” http://hardwarefun.com 35
Connecting Arduino to Internet  Ethernet Shield  WIFI Shield  3G Shield  Using another intermediate component http://hardwarefun.com 36
Demo of network connectivity using Arduino http://hardwarefun.com 37
Let’s take a break  http://hardwarefun.com 38
Raspberry Pi
Credit Card Sized Computer http://hardwarefun.com 40
GPIO Pins http://hardwarefun.com 41 http://learn.adafruit.com/assets/3052
Setup Python sudo apt-get install python-dev sudo apt-get install python-rpi.gpio http://hardwarefun.com 42
Set the status of GPIO Pins https://github.com/sudar/r http://hardwarefun.com asp4b3erry-pi-sketches/blob/master/led-blink/led-blink.py
Set the status of GPIO Pins import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) GPIO.setup(12, GPIO.OUT) try: while True: GPIO.output(12, GPIO.HIGH) time.sleep(1) GPIO.output(12, GPIO.LOW) time.sleep(1) finally: GPIO.cleanup() https://github.com/sudar/raspberry-http://hardwarefun.com 44 pi-sketches/blob/master/led-blink/led-blink.py
Demo Let there be Light https://github.com/sudar/r http://hardwarefun.com 45aspberry-pi-sketches/blob/master/led-blink/led-blink.py
Changing the brightness of the LED import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) GPIO.setup(12, GPIO.OUT) p = GPIO.PWM(12, 50) # channel=12 frequency=50Hz p.start(0) try: while True: for dc in range(0, 101, 5): p.ChangeDutyCycle(dc) time.sleep(0.1) for dc in range(100, -1, -5): p.ChangeDutyCycle(dc) time.sleep(0.1) finally: p.stop() GPIO.cleanup() http://hardwarefun.com 46 https://github.com/sudar/raspberry-pi-sketches/blob/master/led-blink/pwm.py
Demo Can you see the brightness changing? https://github.com/sudar/raspberry-http://hardwarefun.com 47 pi-sketches/blob/master/led-blink/pwm.py
Reading the status of the Pin import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) try: while True: if GPIO.input(11): print "Button is on" else: print "Button is off" time.sleep(0.1) finally: GPIO.cleanup() http://hardwarefun.com 48 https://github.com/sudar/raspberry-pi-sketches/blob/master/button-input/button-input.py
Reading the status of the Pin http://hardwarefun.com 49 https://github.com/sudar/raspberry-pi-sketches/blob/master/button-input/button-input.py
Demo What happens when the button is pressed? http://hardwarefun.com 50 https://github.com/sudar/raspberry-pi-sketches/blob/master/button-input/button-input.py
Combining Input and Output import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(12, GPIO.OUT) try: while True: if GPIO.input(11): print "Button is on" GPIO.output(12, 1) else: GPIO.output(12, 0) time.sleep(0.1) finally: GPIO.cleanup() http://hardwarefun.com 51 https://github.com/sudar/raspberry-pi-sketches/blob/master/button-and-led/button-and-led.py
Combining Input and Output http://hardwarefun.com 52 https://github.com/sudar/raspberry-pi-sketches/blob/master/button-and-led/button-and-led.py
Demo Let’s control the LED by pressing the button http://hardwarefun.com 53 https://github.com/sudar/raspberry-pi-sketches/blob/master/button-and-led/button-and-led.py
What more can be done? http://hardwarefun.com 54
More protocols  I2C  SPI  Serial http://hardwarefun.com 55
Interacting with webcam  “PyGame” provides easy interface  Can get fancy using “opencv”  Both USB and GPIO interface are supported http://hardwarefun.com 56
Distributed Computing  Each Pi can be used as cheap node  Form grids using a cluster of Pi’s  Can share CPU, memory and disk space http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/ distributed-computing/ http://hardwarefun.com 57
Limitations  No built-in Analog to Digital support  Can’t run Inductive load (motors)  Is not real-time (CPU might be busy)  No “safe circuits” present  Operates at 3.3V and is not directly compatible with Arduino voltage http://hardwarefun.com 58
Arduino vs Raspberry Pi for IoT http://hardwarefun.com 59
Advantages of Raspberry Pi  Entire Linux software stack is available  It is very easy to connect to internet  Can be programmed using variety of programming languages http://hardwarefun.com 60
Disadvantage of Raspberry Pi  Accessing hardware is not real-time. If the CPU is busy, then interfacing with hardware can be delayed  No built-in Analog to Digital converter available  Does not have enough power to drive inductive loads  The hardware design is not open source. Even though it is not a big deal, for some people it might a deal breaker http://hardwarefun.com 61
Advantages of Arduino  Very easy to get started  Very easy to extend it and has tons of user contributed shields and libraries. Shields are available to do pretty much anything  Can be used to for real-time applications  Everything (both hardware, software and IDE) are open source  Not much programming knowledge needed to do basic stuff http://hardwarefun.com 62
Disadvantages of Arduino  Not very powerful when compared with Raspberry Pi (Micro processor vs Micro controller)  You need to program using either Arduino or C/C++ (or assembly if you really want to)  Connecting to internet is slightly difficult (you have shields and libraries, but is not straight forward), but not impossible. http://hardwarefun.com 63
In Short.. Feature Raspberry Pi Arduino Processor Speed 700 MHz 16 MHz Programming Language No limit Arduino, C/C++ Real-time Hardware No real-time In real-time Analog to Digital Convertor No Yes Hardware Design Closed source Open source Internet Connection Very easy Not easy, but doable http://hardwarefun.com 64
My Solution? http://hardwarefun.com 65
Use both together  Best of both worlds http://hardwarefun.com 66 http://learn.adafruit.com/assets/3199 http://learn.adafruit.com/assets/2123
Links  Source code - https://github.com/sudar/raspberry-pi-sketches/  My blog - http://hardwarefun.com  Python GPIO - https://code.google.com/p/raspberry-gpio- python/  Distributed computing using Pi - http://www.cl.cam.ac.uk/projects/raspberrypi/tutorial s/distributed-computing/ http://hardwarefun.com 67
Links  Arduino – http://arduino.cc  Asimi – A simple bot using Arduino http://hardwarefun.com/project/asimi  Getting started with hardware programming http://hardwarefun.com/tutorials/getting-started-with-hardware- programming  Getting started with Arduino http://hardwarefun.com/tutorials/getting-started-with-arduino- and-avr http://hardwarefun.com 68
Questions Thank You Sudar Muthu (@sudarmuthu) http://hardwarefun.com/ https://github.com/sudar/arduino-robotics-workshop https://github.com/sudar/raspberry-pi-sketches http://hardwarefun.com 69

Recommended

PPT
Building IoT with Arduino Day One
PPTX
Introduction to Internet of Things Hardware
PPTX
Internet of things using Raspberry Pi
PPT
Introduction to Arduino & Raspberry Pi
PDF
IoT Arduino UNO, RaspberryPi with Python, RaspberryPi Programming using Pytho...
PDF
Introduction to Arduino Programming: Features of Arduino
PPTX
HOME INTRUSION DETECTION.pptx
PDF
15CS81 Module1 IoT
PPT
Intro to Arduino
PPTX
Microprocessor & Micro-controller
PPT
IoT with Arduino
PPTX
Basics of arduino uno
PPTX
Introduction to Arduino
PDF
Esp8266 basics
PPTX
Lesson sample introduction to arduino
PDF
Arduino Lecture 1 - Introducing the Arduino
PDF
Report on arduino
PPTX
Arduino vs Raspberry Pi
PPT
Arduino
PDF
Beginners: What is Industrial IoT (IIoT)
 
PDF
Introduction to Raspberrypi
PPTX
Tinkercad Workshop PPT, Dept. of ECE.pptx
PDF
Arduino presentation
PDF
Introduction of Arduino Uno
PPTX
PPT ON Arduino
PPTX
Esp8266 NodeMCU
PPTX
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauri
PPTX
PPT on Bluetooth Based Wireless Sensor Networks
PPTX
IoT applications With Arduino coding and real life examples
PDF
Arduino - Learning.pdf

More Related Content

PPT
Building IoT with Arduino Day One
PPTX
Introduction to Internet of Things Hardware
PPTX
Internet of things using Raspberry Pi
PPT
Introduction to Arduino & Raspberry Pi
PDF
IoT Arduino UNO, RaspberryPi with Python, RaspberryPi Programming using Pytho...
PDF
Introduction to Arduino Programming: Features of Arduino
PPTX
HOME INTRUSION DETECTION.pptx
PDF
15CS81 Module1 IoT
Building IoT with Arduino Day One
Introduction to Internet of Things Hardware
Internet of things using Raspberry Pi
Introduction to Arduino & Raspberry Pi
IoT Arduino UNO, RaspberryPi with Python, RaspberryPi Programming using Pytho...
Introduction to Arduino Programming: Features of Arduino
HOME INTRUSION DETECTION.pptx
15CS81 Module1 IoT

What's hot

PPT
Intro to Arduino
PPTX
Microprocessor & Micro-controller
PPT
IoT with Arduino
PPTX
Basics of arduino uno
PPTX
Introduction to Arduino
PDF
Esp8266 basics
PPTX
Lesson sample introduction to arduino
PDF
Arduino Lecture 1 - Introducing the Arduino
PDF
Report on arduino
PPTX
Arduino vs Raspberry Pi
PPT
Arduino
PDF
Beginners: What is Industrial IoT (IIoT)
 
PDF
Introduction to Raspberrypi
PPTX
Tinkercad Workshop PPT, Dept. of ECE.pptx
PDF
Arduino presentation
PDF
Introduction of Arduino Uno
PPTX
PPT ON Arduino
PPTX
Esp8266 NodeMCU
PPTX
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauri
PPTX
PPT on Bluetooth Based Wireless Sensor Networks
Intro to Arduino
Microprocessor & Micro-controller
IoT with Arduino
Basics of arduino uno
Introduction to Arduino
Esp8266 basics
Lesson sample introduction to arduino
Arduino Lecture 1 - Introducing the Arduino
Report on arduino
Arduino vs Raspberry Pi
Arduino
Beginners: What is Industrial IoT (IIoT)
 
Introduction to Raspberrypi
Tinkercad Workshop PPT, Dept. of ECE.pptx
Arduino presentation
Introduction of Arduino Uno
PPT ON Arduino
Esp8266 NodeMCU
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauri
PPT on Bluetooth Based Wireless Sensor Networks

Similar to Using arduino and raspberry pi for internet of things

PPTX
IoT applications With Arduino coding and real life examples
PDF
Arduino - Learning.pdf
PPTX
Arduino
PPTX
Getting started with arduino workshop
PPTX
Arduino Robotics workshop Day1
PPTX
Getting Started with Raspberry Pi and Arduino
PPTX
M.Tech Internet of Things Unit - III.pptx
PPTX
Arduino slides
PPTX
Arduino Workshop Slides
PDF
Arduino spooky projects_class1
PDF
02 Sensors and Actuators Understand .pdf
PDF
#startathon2.0 - Arduino
PPTX
Arduino Slides With Neopixels
PDF
Arduino Comic-Jody Culkin-2011
PDF
Arduino comic v0004
PPT
13223971.ppt
PPTX
Internet of Things prescribed by University
PDF
Syed IoT - module 5
PDF
Arduino, Raspberry Pi, and Making
PPTX
Introduction to Arduino Webinar
IoT applications With Arduino coding and real life examples
Arduino - Learning.pdf
Arduino
Getting started with arduino workshop
Arduino Robotics workshop Day1
Getting Started with Raspberry Pi and Arduino
M.Tech Internet of Things Unit - III.pptx
Arduino slides
Arduino Workshop Slides
Arduino spooky projects_class1
02 Sensors and Actuators Understand .pdf
#startathon2.0 - Arduino
Arduino Slides With Neopixels
Arduino Comic-Jody Culkin-2011
Arduino comic v0004
13223971.ppt
Internet of Things prescribed by University
Syed IoT - module 5
Arduino, Raspberry Pi, and Making
Introduction to Arduino Webinar

More from Sudar Muthu

PPTX
A quick preview of WP CLI - Chennai WordPress Meetup
PDF
WordPress Developer tools
PDF
WordPress Developer Tools to increase productivity
PDF
Unit testing for WordPress
PDF
Unit testing in php
PPTX
How arduino helped me in life
PPTX
Having fun with hardware
PPTX
Python in raspberry pi
PPTX
Hack 101 at IIT Kanpur
PPTX
PureCSS open hack 2013
PPTX
Pig workshop
PPTX
Arduino Robotics workshop day2
PPTX
Hands on Hadoop and pig
PPTX
Lets make robots
PPTX
Capabilities of Arduino (including Due)
PPTX
Controlling robots using javascript
PPTX
Picture perfect hacks with flickr API
PPTX
Hacking 101
PPTX
Capabilities of Arduino
PPTX
Introduction to node.js GDD
A quick preview of WP CLI - Chennai WordPress Meetup
WordPress Developer tools
WordPress Developer Tools to increase productivity
Unit testing for WordPress
Unit testing in php
How arduino helped me in life
Having fun with hardware
Python in raspberry pi
Hack 101 at IIT Kanpur
PureCSS open hack 2013
Pig workshop
Arduino Robotics workshop day2
Hands on Hadoop and pig
Lets make robots
Capabilities of Arduino (including Due)
Controlling robots using javascript
Picture perfect hacks with flickr API
Hacking 101
Capabilities of Arduino
Introduction to node.js GDD

Recently uploaded

PDF
Cybersecurity: Safeguarding Digital Assets
PPTX
Software Analysis &Design ethiopia chap-2.pptx
PPTX
AI in Cybersecurity: Digital Defense by Yasir Naveed Riaz
PDF
TrustArc Webinar - Looking Ahead: The 2026 Privacy Landscape
PDF
Vibe Coding vs. Spec-Driven Development [Free Meetup]
PPTX
Chapter 3 Introduction to number system.pptx
PPTX
Coded Agents – with UiPath SDK + LangGraph [Virtual Hands-on Workshop]
PDF
Day 5 - Red Team + Blue Team in the Cloud - 2nd Sight Lab Cloud Security Class
PDF
The year in review - MarvelClient in 2025
PPTX
cybercrime in Information security .pptx
PDF
Real-Time Data Insight Using Microsoft Forms for Business
PDF
DevFest El Jadida 2025 - Product Thinking
PDF
Data Virtualization in Action: Scaling APIs and Apps with FME
PDF
The major tech developments for 2026 by Pluralsight, a research and training ...
PPTX
From Backup to Resilience: How MSPs Are Preparing for 2026
 
PPTX
Building Cyber Resilience for 2026: Best Practices for a Secure, AI-Driven Bu...
PDF
December Patch Tuesday
 
PPTX
Conversational Agents – Building Intelligent Assistants [Virtual Hands-on Wor...
PDF
Decoding the DNA: The Digital Networks Act, the Open Internet, and IP interco...
PPTX
Cloud-and-AI-Platform-FY26-Partner-Playbook.pptx
Cybersecurity: Safeguarding Digital Assets
Software Analysis &Design ethiopia chap-2.pptx
AI in Cybersecurity: Digital Defense by Yasir Naveed Riaz
TrustArc Webinar - Looking Ahead: The 2026 Privacy Landscape
Vibe Coding vs. Spec-Driven Development [Free Meetup]
Chapter 3 Introduction to number system.pptx
Coded Agents – with UiPath SDK + LangGraph [Virtual Hands-on Workshop]
Day 5 - Red Team + Blue Team in the Cloud - 2nd Sight Lab Cloud Security Class
The year in review - MarvelClient in 2025
cybercrime in Information security .pptx
Real-Time Data Insight Using Microsoft Forms for Business
DevFest El Jadida 2025 - Product Thinking
Data Virtualization in Action: Scaling APIs and Apps with FME
The major tech developments for 2026 by Pluralsight, a research and training ...
From Backup to Resilience: How MSPs Are Preparing for 2026
 
Building Cyber Resilience for 2026: Best Practices for a Secure, AI-Driven Bu...
December Patch Tuesday
 
Conversational Agents – Building Intelligent Assistants [Virtual Hands-on Wor...
Decoding the DNA: The Digital Networks Act, the Open Internet, and IP interco...
Cloud-and-AI-Platform-FY26-Partner-Playbook.pptx

Using arduino and raspberry pi for internet of things

  • 1.
    Using Arduino andRaspberry Pi for Internet of Things Sudar Muthu (@sudarmuthu) http://hardwarefun.com/ http://github.com/sudar
  • 2.
    Who am I? Research Engineer by profession  I build robots as a hobby  Playing with Arduino for more than 4 years  Blogger about Arduino at http://hardwarefun.com  Moderator for Arduino India forum http://hardwarefun.com 2
  • 3.
    Objective  IntroduceArduino  Introduce Raspberry Pi  Emphasis on IoT  See how both can be used for IoT http://hardwarefun.com 3
  • 4.
  • 5.
    What is Arduino? Visual Basic for hardware  Includes both Hardware and software http://hardwarefun.com 5 Photo credit Arduino team
  • 6.
    Different Arduino types Arduino Uno (The one I am going to use today)  Arduino Mega  Arduino Due  Lillypad  Arduino BT  Arduino Ethernet  .. and clones http://hardwarefun.com 6
  • 7.
    Getting to knowthe Arduino http://hardwarefun.com 7
  • 8.
    Specs (Uno, Leonardo)Type Value Microcontroller ATmega328 Operating Voltage 5v Digital I/O Pins 14 (of which 6 provide PWM output) Analog Input Pins 6 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 http://hardwarefun.com 8
  • 9.
    Identify these componentsin  Microcontroller  Power jacket  USB jacket  Digital pins  Analog pins  Reset button Arduino http://hardwarefun.com 9
  • 10.
    Identify these componentsin Arduino  Voltage Regulator  Power Pins (how many are there?)  Ground Pins (how many are there?)  Vin Pin  Rx and Tx Pins  ICSP Headers http://hardwarefun.com 10
  • 11.
    Identify these componentsin  Power Led  Rx and Tx Led’s  Test Led  Crystal  Anything else? Arduino http://hardwarefun.com 11
  • 12.
    Powering up Arduinohttp://hardwarefun.com 12
  • 13.
    Different ways topower up Arduino  Using USB cable  Using DC power jacket  Giving voltage directly into Vin pin  Giving regulated voltage directly into 5V pin http://hardwarefun.com 13
  • 14.
    Setting up Arduinohttp://hardwarefun.com 14
  • 15.
    Testing the setupwith a “Hello World” program http://hardwarefun.com 15
  • 16.
  • 17.
    Making a LEDblink  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  http://hardwarefun.com 17
  • 18.
    People with electronicsbackground Did I miss anything? http://hardwarefun.com 18
  • 19.
    People with electronicsbackground Did I miss anything? Hint: Ohm’s Law http://hardwarefun.com 19
  • 20.
    Anatomy of anArduino sketch http://hardwarefun.com 20
  • 21.
    Printing values throughSerial  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  SoftwareSerial is also available http://hardwarefun.com 21
  • 22.
  • 23.
    How to usea breadboard  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 http://hardwarefun.com 23
  • 24.
    Digital Input andOutput http://hardwarefun.com 24
  • 25.
  • 26.
    Digital Output TheLED blink that we did at “setting up Arduino” is Digital output http://hardwarefun.com 26
  • 27.
  • 28.
    Reading Analog valuesfrom sensors  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 http://hardwarefun.com 28
  • 29.
    Control an LEDbased on light void setup(){ pinMode(13, OUTPUT); } void loop(){ int val = analogRead(A0); if (val > 50) { digitalWrite(13, HIGH); } else { digitalWrite(13, LOW); } } http://hardwarefun.com 29
  • 30.
  • 31.
    Analog Output What is PWM?  Analog like behavior using digital output  Works by switching the LED on and off regularly  Changing the brightness of a Led http://hardwarefun.com 31
  • 32.
    This is justthe tip of an iceberg http://hardwarefun.com 32 There are tons of other features to Arduino which I have not talked about
  • 33.
    Internet of Thingshttp://hardwarefun.com 33
  • 34.
    http://hardwarefun.com 34 "Internetof Things" by Wilgengebroed on Flickr
  • 35.
    LoT is anoverloaded term But I like this definition… “The Internet of Things is the interconnection of uniquely identifiable embedded computing devices within the existing Internet infrastructure” http://hardwarefun.com 35
  • 36.
    Connecting Arduino toInternet  Ethernet Shield  WIFI Shield  3G Shield  Using another intermediate component http://hardwarefun.com 36
  • 37.
    Demo of networkconnectivity using Arduino http://hardwarefun.com 37
  • 38.
    Let’s take abreak  http://hardwarefun.com 38
  • 39.
  • 40.
    Credit Card SizedComputer http://hardwarefun.com 40
  • 41.
    GPIO Pins http://hardwarefun.com41 http://learn.adafruit.com/assets/3052
  • 42.
    Setup Python sudoapt-get install python-dev sudo apt-get install python-rpi.gpio http://hardwarefun.com 42
  • 43.
    Set the statusof GPIO Pins https://github.com/sudar/r http://hardwarefun.com asp4b3erry-pi-sketches/blob/master/led-blink/led-blink.py
  • 44.
    Set the statusof GPIO Pins import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) GPIO.setup(12, GPIO.OUT) try: while True: GPIO.output(12, GPIO.HIGH) time.sleep(1) GPIO.output(12, GPIO.LOW) time.sleep(1) finally: GPIO.cleanup() https://github.com/sudar/raspberry-http://hardwarefun.com 44 pi-sketches/blob/master/led-blink/led-blink.py
  • 45.
    Demo Let therebe Light https://github.com/sudar/r http://hardwarefun.com 45aspberry-pi-sketches/blob/master/led-blink/led-blink.py
  • 46.
    Changing the brightnessof the LED import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) GPIO.setup(12, GPIO.OUT) p = GPIO.PWM(12, 50) # channel=12 frequency=50Hz p.start(0) try: while True: for dc in range(0, 101, 5): p.ChangeDutyCycle(dc) time.sleep(0.1) for dc in range(100, -1, -5): p.ChangeDutyCycle(dc) time.sleep(0.1) finally: p.stop() GPIO.cleanup() http://hardwarefun.com 46 https://github.com/sudar/raspberry-pi-sketches/blob/master/led-blink/pwm.py
  • 47.
    Demo Can yousee the brightness changing? https://github.com/sudar/raspberry-http://hardwarefun.com 47 pi-sketches/blob/master/led-blink/pwm.py
  • 48.
    Reading the statusof the Pin import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) try: while True: if GPIO.input(11): print "Button is on" else: print "Button is off" time.sleep(0.1) finally: GPIO.cleanup() http://hardwarefun.com 48 https://github.com/sudar/raspberry-pi-sketches/blob/master/button-input/button-input.py
  • 49.
    Reading the statusof the Pin http://hardwarefun.com 49 https://github.com/sudar/raspberry-pi-sketches/blob/master/button-input/button-input.py
  • 50.
    Demo What happenswhen the button is pressed? http://hardwarefun.com 50 https://github.com/sudar/raspberry-pi-sketches/blob/master/button-input/button-input.py
  • 51.
    Combining Input andOutput import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(12, GPIO.OUT) try: while True: if GPIO.input(11): print "Button is on" GPIO.output(12, 1) else: GPIO.output(12, 0) time.sleep(0.1) finally: GPIO.cleanup() http://hardwarefun.com 51 https://github.com/sudar/raspberry-pi-sketches/blob/master/button-and-led/button-and-led.py
  • 52.
    Combining Input andOutput http://hardwarefun.com 52 https://github.com/sudar/raspberry-pi-sketches/blob/master/button-and-led/button-and-led.py
  • 53.
    Demo Let’s controlthe LED by pressing the button http://hardwarefun.com 53 https://github.com/sudar/raspberry-pi-sketches/blob/master/button-and-led/button-and-led.py
  • 54.
    What more canbe done? http://hardwarefun.com 54
  • 55.
    More protocols I2C  SPI  Serial http://hardwarefun.com 55
  • 56.
    Interacting with webcam “PyGame” provides easy interface  Can get fancy using “opencv”  Both USB and GPIO interface are supported http://hardwarefun.com 56
  • 57.
    Distributed Computing Each Pi can be used as cheap node  Form grids using a cluster of Pi’s  Can share CPU, memory and disk space http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/ distributed-computing/ http://hardwarefun.com 57
  • 58.
    Limitations  Nobuilt-in Analog to Digital support  Can’t run Inductive load (motors)  Is not real-time (CPU might be busy)  No “safe circuits” present  Operates at 3.3V and is not directly compatible with Arduino voltage http://hardwarefun.com 58
  • 59.
    Arduino vs RaspberryPi for IoT http://hardwarefun.com 59
  • 60.
    Advantages of RaspberryPi  Entire Linux software stack is available  It is very easy to connect to internet  Can be programmed using variety of programming languages http://hardwarefun.com 60
  • 61.
    Disadvantage of RaspberryPi  Accessing hardware is not real-time. If the CPU is busy, then interfacing with hardware can be delayed  No built-in Analog to Digital converter available  Does not have enough power to drive inductive loads  The hardware design is not open source. Even though it is not a big deal, for some people it might a deal breaker http://hardwarefun.com 61
  • 62.
    Advantages of Arduino Very easy to get started  Very easy to extend it and has tons of user contributed shields and libraries. Shields are available to do pretty much anything  Can be used to for real-time applications  Everything (both hardware, software and IDE) are open source  Not much programming knowledge needed to do basic stuff http://hardwarefun.com 62
  • 63.
    Disadvantages of Arduino Not very powerful when compared with Raspberry Pi (Micro processor vs Micro controller)  You need to program using either Arduino or C/C++ (or assembly if you really want to)  Connecting to internet is slightly difficult (you have shields and libraries, but is not straight forward), but not impossible. http://hardwarefun.com 63
  • 64.
    In Short.. FeatureRaspberry Pi Arduino Processor Speed 700 MHz 16 MHz Programming Language No limit Arduino, C/C++ Real-time Hardware No real-time In real-time Analog to Digital Convertor No Yes Hardware Design Closed source Open source Internet Connection Very easy Not easy, but doable http://hardwarefun.com 64
  • 65.
  • 66.
    Use both together Best of both worlds http://hardwarefun.com 66 http://learn.adafruit.com/assets/3199 http://learn.adafruit.com/assets/2123
  • 67.
    Links  Sourcecode - https://github.com/sudar/raspberry-pi-sketches/  My blog - http://hardwarefun.com  Python GPIO - https://code.google.com/p/raspberry-gpio- python/  Distributed computing using Pi - http://www.cl.cam.ac.uk/projects/raspberrypi/tutorial s/distributed-computing/ http://hardwarefun.com 67
  • 68.
    Links  Arduino– http://arduino.cc  Asimi – A simple bot using Arduino http://hardwarefun.com/project/asimi  Getting started with hardware programming http://hardwarefun.com/tutorials/getting-started-with-hardware- programming  Getting started with Arduino http://hardwarefun.com/tutorials/getting-started-with-arduino- and-avr http://hardwarefun.com 68
  • 69.
    Questions Thank YouSudar Muthu (@sudarmuthu) http://hardwarefun.com/ https://github.com/sudar/arduino-robotics-workshop https://github.com/sudar/raspberry-pi-sketches http://hardwarefun.com 69

Editor's Notes

  • #35 "Internet of Things" by Wilgengebroed on Flickr - Cropped and sign removed from Internet of things signed by the author.jpg. Licensed under Creative Commons Attribution 2.0 via Wikimedia Commons - http://commons.wikimedia.org/wiki/File:Internet_of_Things.jpg#mediaviewer/File:Internet_of_Things.jpg

[8]ページ先頭

©2009-2025 Movatter.jp