Intro to Arduino at Deezmaker by Qtechknow

779 views

Published on

This was my presentation for the Intro to Arduino class held at Deezmaker 3D Printer Store/Hackerspace 4/6/13. I, Quin/Qtechknow, taught this class along with my ArduSensor Fun Pack, which is available on my website, www.qtechknow.com. We went over some key concepts of Arduino, open source, and circuits. Enjoy!!!

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
779
On SlideShare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
18
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Intro to Arduino at Deezmaker by Qtechknow

  1. 1. Intro to Arduino Class Deezmaker 3D Printer Store and Hackerspace Taught by Quin 4/6/13Saturday, April 6, 13
  2. 2. Thank you to SparkFun for sharing the original presentation!Saturday, April 6, 13
  3. 3. What is Open Source??? Open source is when you release your design files (a.k.a. the PCB files, schematic) to the public, so that anyone that wants to learn more about the PCB, can learn for free. When you release files for a new project you have made, but you remade/remixed the files that someone else made, you have to credit them.Saturday, April 6, 13
  4. 4. Schedule • Getting started with Arduino and electronics • Project 1 & 2 • Break • Project 3 & 4 • Explaining More Code • Project 5 & 6 • Q&A + Free Project TimeSaturday, April 6, 13
  5. 5. Arduino Board “Strong Friend” Created in Ivrea, Italy in 2005 by Massimo Banzi & David Cuartielles Open Source Hardware Atmel Processor Coding is accessible/easy (C++, Processing)Saturday, April 6, 13
  6. 6. Why do I want an Arduino? Arduino is a 8-bit prototyping system that is easy for the modern developer, designer, hacker, kid, or someone that has no experience in this type of genre to use. But why is important to all of us?Saturday, April 6, 13
  7. 7. Saturday, April 6, 13
  8. 8. Arduino Shields PCB Built Shield Inserted ShieldSaturday, April 6, 13
  9. 9. Arduino Shields Micro SD MP3 Trigger JoystickSaturday, April 6, 13
  10. 10. ArduSensors - ‘Mini Shields’Saturday, April 6, 13
  11. 11. Components Name Image Type Function Notes Digital Input Closes or Polarized, Button opens circuit needs resistor Analog Input Variable Trimpot resistor LDR Analog Input Variable Also known as resistor photoresistor Temp Analog Input Variable resistor Sensor Flex Sensor Analog Input Variable resistor Dig. & 16,777,216 Ooh... So RGB LED Analog Output different pretty. colorsSaturday, April 6, 13
  12. 12. Polarity Polarity is when there are two or more different sides (or leads) of a component that have different qualities that can not be reversed. Examples: batteries, LEDs, buttonsSaturday, April 6, 13
  13. 13. Power (+5V) and Ground (GND) Power is the current that goes through the circuit, and ground is the current return path (collector). Always make sure that Power and Ground never touch directly, or the circuit will short, and become very hot. Make sure to not use over 10V, just 5V, and 3.3V, so no shock will occur.Saturday, April 6, 13
  14. 14. What’s a Breadboard? One of the most useful tools in an engineer or Maker’s toolkit. The four most important things to remember: • Breadboards are very easy to prototype with • A breadboard is easier than soldering • A lot of those little holes are connected, which ones? • Breadboards can break, if you force them too much.Saturday, April 6, 13
  15. 15. What’s a Breadboard?Saturday, April 6, 13
  16. 16. Analog and Digital • All Arduino signals are either Analog or Digital • All computers including Arduino, only understand Digital • We need a way to convert the analog signals into digital signals, so that our Arduino can process them.Saturday, April 6, 13
  17. 17. Analog to Digital Conversion An ADC is a device that samples a continuous quantity of analog signals (sensor signals), compares it to the time, then outputs a digital signal to the Arduino. It then turns the digital signals into 1024 different values. The ADC (analog) compatible pins on the Arduino are A0, A1, A2, A3, A4, and A5.Saturday, April 6, 13
  18. 18. I/O, or Input/Output Input is any signal entering an electrical system/Arduino. Output is any signal exiting an electrical system.Saturday, April 6, 13
  19. 19. Output Output is always Digital To Output a Digital signal (On or Off) use this code: digitalWrite (pinNumber, value); Where value is HIGH (on) or LOW (off), both in capsSaturday, April 6, 13
  20. 20. Output To output a signal that pretends to be analog (anywhere in between on and off), you will have to use a PWM pin. Use this code to output an ‘analog’ signal: analogWrite (pinNumber, value); Where value is a number 0 - 255. PWM is available on Arduino Leonardo digital pins 3, 5, 6, 9, 10, 11, and 13, and marked with a ‘~’.Saturday, April 6, 13
  21. 21. Output Using a Digital signal that pretends to be an Analog signal is called Pulse Width Modulation Use Pulse Width Modulation, or PWM, for anything that requires a signal between HIGH and LOW (1-254, with 0 being off and 255 being on) PWM turns the output on to off very fast, so fast that we can’t see it. By changing the 0 - 255 #, we can change the width of these signals.Saturday, April 6, 13
  22. 22. Output Output is always Digital, even when it’s P.W.M. For P.W.M. the Arduino pin turns on, then off very fast P.W.M. Signal @ 25% P.W.M. Signal @ 75% P.W.M. Signal risingSaturday, April 6, 13
  23. 23. Arduino IDE The Arduino IDE (Integrated Development Environment) is where we develop our code, and deploy/ upload the code to the Arduino Leonardo Board. You can download the latest software here: Arduino 1.0.4: http://arduino.cc/en/main/softwareSaturday, April 6, 13
  24. 24. Installing Drivers for Mac The first time you plug a Leonardo into a Mac, the "Keyboard Setup Assistant" will launch. Theres nothing to configure with the Leonardo, so you can close this dialogue by clicking the red button in the top left of the window.Saturday, April 6, 13
  25. 25. Installing Drivers for Windows This method has been tested on Windows XP and 7: • Plug in your board and wait for Windows to begin its driver installation process. If the installer does not launch automatically, Navigate to the Windows Device Manager (Start>Control Panel>Hardware) and find the Arduino Leonardo listing. Right click and choose Update driver. • If prompted to search for drivers online, choose "No, not this time". And click NextSaturday, April 6, 13
  26. 26. Installing Drivers for WindowsSaturday, April 6, 13
  27. 27. Installing Drivers for Windows • When asked to install automatically or from a specific location, select "Install from a list or specific location" and press NextSaturday, April 6, 13
  28. 28. Installing Drivers for Windows • Choose "Search for the best driver in these locations", and check the box "incude this location in the search". Click the Browse button and navigate to your Arduino 1.0.1 or later installation. Select the drivers folder an click OKSaturday, April 6, 13
  29. 29. Installing Drivers for WindowsSaturday, April 6, 13
  30. 30. Installing Drivers for Windows Click Next. You will receive a notification that the Leonardo has not passed Windows Logo testing. Click on the button Continue AnywaySaturday, April 6, 13
  31. 31. Installing Drivers for Windows • After a few moments, a window will tell you the wizard has finished installing software for Arduino Leonardo. Press the Finish button (from arduino.cc)Saturday, April 6, 13
  32. 32. Saturday, April 6, 13
  33. 33. Saturday, April 6, 13
  34. 34. Board TypeSaturday, April 6, 13
  35. 35. Serial Port / COM PortSaturday, April 6, 13
  36. 36. Which COM/Serial Port? Mac: /dev/tty.usbmodemfd131 Interchangeable #: Windows: COM# Device Manager: Start>Control Panel>System & Security>Device Manager>PortsSaturday, April 6, 13
  37. 37. Circuit 1: Basic BlinkSaturday, April 6, 13
  38. 38. How to get the sketch: Go to File>Examples>01.Basics>BlinkSaturday, April 6, 13
  39. 39. 39Saturday, April 6, 13
  40. 40. Parts of the SketchSaturday, April 6, 13
  41. 41. void setup() {} 41Saturday, April 6, 13
  42. 42. void loop ( ) { }Saturday, April 6, 13
  43. 43. Why do I make a comment? • Comments are great ways to remind you what you did, teach other people what that code means, or to make a long description for your whole piece of code for licenses, date, and authorSaturday, April 6, 13
  44. 44. Comments • Comments are ignored by the compiler/verifier • Comments can be anywhere • Comments can start with a // for a one-line comment • Another type of comment is multiple lines and starts with a /* and ends with a */Saturday, April 6, 13
  45. 45. Example of Comment:Saturday, April 6, 13
  46. 46. Input Input is any signal entering an electrical system •Both digital and analog sensors are forms of input •Input can also take many other forms: Keyboards, a mouse, buttons, light sensors, or just plain voltage from a circuitSaturday, April 6, 13
  47. 47. Analog Input • To connect an analog Input to your Arduino, use Analog/ADC Pins # 0 - 5 • To get an analog reading, use the code: analogRead(pinNumber); • Analog Input varies from 0 to 1023 on an ArduinoSaturday, April 6, 13
  48. 48. Downloading Code https://github.com/Qtechknow/ Arduino-Code/zipball/master/Saturday, April 6, 13
  49. 49. Circuit 2: Analog ReadingSaturday, April 6, 13
  50. 50. Saturday, April 6, 13
  51. 51. BreakSaturday, April 6, 13
  52. 52. Digital Sensors/Digital Input • Digital Input could be a switch or a button • To connect digital input to your Arduino use Digital Pins # 0 – 13 (Although pins # 0 & 1 are also used for serial) • Digital Input needs a pinMode command (in setup): pinMode(pinNumber, INPUT); Make sure to use caps for INPUT • To get a digital reading: digitalRead(pinNumber); • Digital Input values are only HIGH (On) or LOW (Off)Saturday, April 6, 13
  53. 53. Digital Sensors/Digital Input • Digital sensors are more straight forward than Analog • No matter what the sensor, there are only two settings: On and Off (for buttons, pressed or not) • Signal is always either HIGH (On) or LOW (Off) • Voltage signal for HIGH will be a little less than 5V on your Arduino Leonardo • Voltage signal for LOW will be 0V, and HIGH will be 5VSaturday, April 6, 13
  54. 54. Parts for Circuit 3: Arduino Leonardo Breadboard Pushbutton (2) LED (2) Resistor - 10K Ohm (2) Resistor - 330 Ohm (2) Jumper WiresSaturday, April 6, 13
  55. 55. Circuit 3: ButtonsSaturday, April 6, 13
  56. 56. `Saturday, April 6, 13
  57. 57. Saturday, April 6, 13
  58. 58. Semicolons Semicolons are needed after every line of code, except for void setup(), void loop(), and a few othersSaturday, April 6, 13
  59. 59. Operators The equals sign = is used to assign a value == is used to compare valuesSaturday, April 6, 13
  60. 60. Operators && is “and” || is “or”Saturday, April 6, 13
  61. 61. Variables Basic variable types: Boolean (on or off) Integer (a number) Character (a letter) String (a phrase/many letters)Saturday, April 6, 13
  62. 62. Declaring Variables Boolean: boolean variableName; Integer: int variableName; Character: char variableName; String: stringName [ ];Saturday, April 6, 13
  63. 63. Assigning Variables Boolean: variableName = true; or variableName = false;Saturday, April 6, 13
  64. 64. Assigning Variables Boolean: variableName = true; or variableName = false; Integer: variableName = 32767; or variableName = -32768;Saturday, April 6, 13
  65. 65. Assigning Variables Boolean: variableName = true; or variableName = false; Integer: variableName = 32767; or variableName = -32768; Character: variableName = ‘A’; or stringName = “Deezmaker”;Saturday, April 6, 13
  66. 66. Variable Scope Where you declare your variables mattersSaturday, April 6, 13
  67. 67. Circuit 4: ArduSensor + LEDSaturday, April 6, 13
  68. 68. Circuit 4: ArduSensor+LEDSaturday, April 6, 13
  69. 69. Saturday, April 6, 13
  70. 70. Common Functions pinMode(pin, kind); (declares pins) analogRead(pin); (reads an analog pin) digitalWrite(pin, state); (tells a pin to turn on (5V), or turn off (0V) if() {} (tells something to do a function, when something else happens for() {} (tells something to do a function over and over)Saturday, April 6, 13
  71. 71. Setup void setup ( ) { Inputs & Outputs are declared in setup, this is done by using the pinMode function This particular example declares digital pin # 13 as an output, remember to use CAPSSaturday, April 6, 13
  72. 72. If Statements if ( this is true ) { do this; }Saturday, April 6, 13
  73. 73. If if ( this is true ) { do this; }Saturday, April 6, 13
  74. 74. Conditional if ( this is true ) { do this; }Saturday, April 6, 13
  75. 75. Action if ( this is true ) { do this; }Saturday, April 6, 13
  76. 76. Else else { do this; }Saturday, April 6, 13
  77. 77. Basic Repetition for (int count = 0; count<10; count++) { //for action code goes here //this could be anything }Saturday, April 6, 13
  78. 78. Basic Repetition for (int count = 0; count<10; count++) { //for action code goes here }Saturday, April 6, 13
  79. 79. Basic Repetition for (int count = 0; count<10; count++) { //for action code goes here }Saturday, April 6, 13
  80. 80. Basic Repetition for (int count = 0; count<10; count++) { //for action code goes here }Saturday, April 6, 13
  81. 81. Basic Repetition for (int count = 0; count<10; count++) { //for action code goes here }Saturday, April 6, 13
  82. 82. Basic Repetition for (int count = 0; count<10; count++) { //for action code goes here }Saturday, April 6, 13
  83. 83. Circuit 5: LED BounceSaturday, April 6, 13
  84. 84. Saturday, April 6, 13
  85. 85. Saturday, April 6, 13
  86. 86. Circuit 6: MeterSaturday, April 6, 13
  87. 87. Saturday, April 6, 13
  88. 88. Saturday, April 6, 13
  89. 89. Q&A and Project timeSaturday, April 6, 13

×