Intro to Arduino
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Intro to Arduino

on

  • 2,977 views

Intro to Arduino Class taught at CRASHspace by Quin (Qtechknow). Originally taught on August 11, 2012 at Crashspace, in LA. This revision patches the diagrams and fixes the code! Thanks to SparkFun ...

Intro to Arduino Class taught at CRASHspace by Quin (Qtechknow). Originally taught on August 11, 2012 at Crashspace, in LA. This revision patches the diagrams and fixes the code! Thanks to SparkFun who shared all of their original slides with me!

Statistics

Views

Total Views
2,977
Views on SlideShare
2,319
Embed Views
658

Actions

Likes
0
Downloads
67
Comments
0

3 Embeds 658

http://lamakerspace.com 654
https://twimg0-a.akamaihd.net 3
https://duckduckgo.com 1

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

CC Attribution-ShareAlike LicenseCC Attribution-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Ask What their name is, and why they took this class, what they dream of making\n
  • \n
  • Hopefully, everyone has. If not, give them the download drive, download to desktop, and then retrieve from them.\n
  • Original Arduino team is 5.\n
  • Projects.\n
  • Explain everything, and have everybody look at theirs. We’re going to use these later.\n
  • These are soldered Joystick Shields. Shields are used to expand the possibilities of the Arduino.\n
  • \n
  • These are commonly used components.\n
  • Take a look at the LEDs, talk about cathode and anode.\n
  • \n
  • \n
  • Look on your Breadboards. On the back, there is some adhesive covering the back, but here’s what’s inside.\n
  • Key concept.\n
  • Look at your Arduino. The bottom right of the Arduino should be all analog pins.\n
  • \n
  • \n
  • Code is a different language than english.\n
  • Have them look at their Arduino and identify the PWM pins.\n
  • \n
  • They have handouts on this.\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Now open up Arduino 1.0.1. Sketches are programs filled with code.\n
  • \n
  • \n
  • Click on Find Arduino...\nNow, plug the USB cable into the Arduino, then into your computer.\nThe correct Serial/COM port should appear. \nRemember this port name.\nPress OK, and you should be done.\n\nFor Macs, this should be something like /dev/tty.usbserialft/\nFor Windows, this should be something above COM 3. COM 1 and 2 are usually reserved for Windows hardware ports.\n
  • This sketch will blink the built in LED.\n
  • File examples basic blink\nOpen arduino\nEncourage delay change\nChange blink to analog write.\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • If you look back at the Blink sketch that we just made, you will see some comments up at the top.\n
  • \n
  • \n
  • \n
  • \n
  • To get the code, go into the folder that you just downloaded, open the ArduSensorPotRead folder, and double click on the file named ArduSensorPotRead.ino.\n
  • Once opening the Serial Monitor (pressing the magnifying glass in the upper right hand corner), you will see that there will be a constant value between 1 and 1000. Now tell them about how to turn it. Once code has been explained, have them change the 1000 to 100 or 10 or 5 or something.\n
  • \n
  • \n
  • \n
  • \n
  • To get this code, go into the previous folder that we downloaded, open up the DigitalinputEx folder, and double click on DigitalinputEx.ino. Write connections on whiteboard.\n
  • When you press one of the buttons, it will light one of the LEDs. When you press the other button, it will light the other LED.\n
  • \n
  • Take a look at the last example. This uses semicolons\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • True=On\nFalse=Off\n
  • anywhere in between those numbers for integers\n
  • A string is a bunch of characters put together, or as we know it, words.\n
  • \n
  • Just plug in your ArduSensor Pot like you did before. This is the same circuit as #2, but a different sketch has been written for a different project.\n
  • This will make the built in LED blink at a certain rate depending on how much you turn the potentiometer.\n
  • \n
  • \n
  • This sets pin 13 as an output. \n
  • This basically says that if the button is pressed, turn the LED on.\n
  • \n
  • \n
  • \n
  • Else means that if the if doesn’t run (basically the if isn’t true), the next function will work. This means that at least one piece of the code will run all of the time.\n
  • If this is zero, and this is ten, this piece of code will run 10 times before moving on to the rest of the code.\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • This project makes the QBar Graph light up proportionally to the value of the potentiometer, making a simple meter.\n
  • \n
  • \n
  • \n

Intro to Arduino Presentation Transcript

  • 1. Intro to Arduino Class Intro to Arduino Held at CRASHspace Taught by Quin 8/11/12
  • 2. Thank you to SparkFun for sharing the original presentation!
  • 3. Schedule• Getting started with Arduino and electronics• Project 1 & 2• Break• Project 3, 4, & 5• Explaining More Code• Q&A + Project Time
  • 4. Arduino Board “Strong Friend” Created in Ivrea, Italyin 2005 by Massimo Banzi & David Cuartielles Open Source Hardware Atmel Processor Coding is accessible (C++, Processing)
  • 5. Why do I want an Arduino?Arduino is a 8-bit prototyping systemthat is easy for the modern developer,designer, hacker, kid, or someone thathas no experience in this type of genreto use.But why is important to all of us?
  • 6. Arduino Shields PCB Built Shield InsertedShield
  • 7. Arduino Shields Micro SD MP3 Trigger Joystick
  • 8. ComponentsName Image Type Function Notes Digital Input Closes or Polarized,Button opens circuit needs resistor Analog Input VariableTrimpot resistorLDR Analog Input Variable Also known as resistor photoresistorTemp Analog Input Variable resistorSensorFlex Sensor Analog Input Variable resistor Dig. & 16,777,216 Ooh... SoRGB LED Analog Output different pretty. colors
  • 9. PolarityPolarity is when there are two or moredifferent sides (or leads) of acomponent that have differentqualities that can not be reversed.Examples: batteries, LEDs, buttons
  • 10. Power (+5V) and Ground (GND)Power is the current that goes throughthe circuit, and ground is the currentreturn path (collector)Always make sure that Power andGround never touch directly, or thecircuit will short.Make sure to not use over 10V, just5V, and 3.3V, so no shock will occur.
  • 11. What’s a Breadboard?One of the most useful tools in an engineer or Maker’s toolkit. The four most important things to remember:• Breadboard is very easy to prototype with• A breadboard is easier than soldering• A lot of those little holes are connected, which ones?• Breadboards can break
  • 12. What’s a Breadboard?
  • 13. Analog and Digital• All Arduino signals are either Analog or Digital• All computers including Arduino, only understand Digital• It is important to understand the difference between Analog and Digital signals since Analog signals require an Analog to Digital conversion
  • 14. Analog to Digital ConversionAn ADC is a device that samples acontinuous quantity of digital signals,compares it to discrete time, thenoutputs an analog signal.The ADC (analog) compatible pins onthe Arduino are A0, A1, A2, A3, A4,and A5
  • 15. I/O, or Input/OutputInput is any signal entering an electrical system.Output is any signal exiting anelectrical system.
  • 16. Output Output is any signal exiting an electrical system• Almost all systems that use physical computingwill have some form of output• Outputs include LEDs, a motor, a piezo buzzer,and an RGB LED
  • 17. Output Output is always DigitalTo Output a Digital signal (On or Off) use thiscode: digitalWrite (pinNumber, value);Where value is HIGH (on) or LOW (off), both incapsTo output a signal that pretends to be Analog, usethis code:analogWrite (pinNumber, value);Where value is a number 0 - 255
  • 18. OutputTo output a signal that pretends to beanalog (anywhere in between on andoff), you will have to use a PWM pin.All PWM pins on the Arduino aremarket with a “~” on the digital side.
  • 19. Output Output is always DigitalUsing a Digital signal that pretends to be anAnalog signal is called Pulse Width ModulationUse Pulse Width Modulation, or P.W.M., foranything that requires a signal between HIGH andLOW (1-254, with 0 being off and 255 being on)P.W.M. is available on Arduino Leonardo digitalpins 3, 5, 6, 9, 10, 11, and 13
  • 20. Installing Drivers for MacThe first time you plug a Leonardo into a Mac, the"Keyboard Setup Assistant" will launch. Theresnothing to configure with the Leonardo, so you canclose this dialogue by clicking the red button in thetop left of the window.
  • 21. Installing Drivers for WindowsThis 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 Next
  • 22. Installing Drivers for Windows
  • 23. Installing Drivers for Windows• When asked to install automatically or from a specific location, select "Install from a list or specific location" and press Next
  • 24. 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 OK
  • 25. Installing Drivers for Windows
  • 26. Installing Drivers for WindowsClick Next. You will receive a notification that the Leonardo has not passed Windows Logo testing. Click on the button Continue Anyway
  • 27. 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)
  • 28. Board Type
  • 29. Serial Port / COM Port
  • 30. Circuit 1: Basic Blink 33
  • 31. 34
  • 32. Parts of the Sketch
  • 33. void setup() {} 36
  • 34. void loop ( ) { }
  • 35. 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 author
  • 36. Comments• Comments are ignored by the compiler• 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 */
  • 37. Example of Comment:
  • 38. Output Output is always Digital, even when it’s P.W.M. For P.W.M. the Arduino pin turns on, then off very fastP.W.M. Signal @ 25% P.W.M. Signal @ 75% P.W.M. Signalrising
  • 39. 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 plainvoltage from a circuit
  • 40. Analog Input• To connect an analog Input to your Arduino, use Analog Pins # 0 - 5• To get an analog reading: analogRead (pinNumber);• Analog Input varies from 0 to 1023 on an Arduino
  • 41. Downloading Codehttps://github.com/Qtechknow/ Arduino-Code/zipball/master/
  • 42. Circuit 2: Analog Reading
  • 43. 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 );
  • 44. 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 Leonardo• Voltage signal for LOW will be 0V on most systems
  • 45. Parts for Circuit 3:Arduino LeonardoBreadboardPushbutton (2)LED (2)Resistor - 10K Ohm (2)Resistor - 330 Ohm (2)Jumper Wire
  • 46. Circuit 3: Buttons
  • 47. SemicolonsSemicolons are needed after every lineof code, except for void setup(), voidloop(), and a few others
  • 48. Operators The equals sign = is used to assign a value== is used to compare values
  • 49. Operators&& is “and” || is “or”
  • 50. VariablesBasic variable types:Boolean (on or off)Integer (a number)Character (a letter)
  • 51. Declaring Variables Boolean: boolean variableName;
  • 52. Declaring Variables Boolean: boolean variableName;Integer: int variableName;
  • 53. Declaring Variables Boolean: boolean variableName; Integer: int variableName;Character: char variableName;
  • 54. Declaring Variables Boolean: boolean variableName; Integer: int variableName;Character: char variableName; String: stringName [ ];
  • 55. Assigning VariablesBoolean: variableName = true; or variableName = false;
  • 56. Assigning VariablesBoolean: variableName = true; or variableName = false; Integer: variableName = 32767; or variableName = -32768;
  • 57. Assigning VariablesBoolean: variableName = true; or variableName = false; Integer: variableName = 32767; or variableName = -32768;Character: variableName = ‘A’; or stringName = “Crashspace”;
  • 58. Variable ScopeWhere you declare your variables matters
  • 59. Circuit 4: ArduSensor + LED
  • 60. Circuit 4: ArduSensor+LED
  • 61. Common FunctionspinMode(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 happensfor() {} (tells something to do a function over and over)
  • 62. Setup void setup ( ) {Inputs & Outputs are declared in setup, this is done by using the pinMode functionThis particular example declares digital pin # 13 as an output, remember to use CAPS
  • 63. If Statementsif ( this is true ) { do this; }
  • 64. Ifif ( this is true ) { do this; }
  • 65. Conditionalif ( this is true ) { do this; }
  • 66. Actionif ( this is true ) { do this; }
  • 67. Elseelse { do this; }
  • 68. Basic Repetitionfor (int count = 0; count<10; count++){//for action code goes here//this could be anything}
  • 69. Basic Repetitionfor (int count = 0; count<10; count++){//for action code goes here}
  • 70. Basic Repetitionfor (int count = 0; count<10; count++){//for action code goes here}
  • 71. Basic Repetitionfor (int count = 0; count<10; count++){//for action code goes here}
  • 72. Basic Repetitionfor (int count = 0; count<10; count++){//for action code goes here}
  • 73. Basic Repetitionfor (int count = 0; count<10; count++){//for action code goes here}
  • 74. Basic Repetitionfor (int count = 0; count<10; count++){//for action code goes here}
  • 75. Circuit 5: Meter
  • 76. Q&A and Project time