SlideShare une entreprise Scribd logo
1  sur  89
Télécharger pour lire hors ligne
Intro to Arduino Class

         Deezmaker 3D Printer Store and Hackerspace
                        Taught by Quin
                            4/6/13


Saturday, April 6, 13
Thank you to SparkFun for
                     sharing the original
                        presentation!




Saturday, April 6, 13
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
Schedule

          •    Getting started with Arduino and electronics
          •    Project 1 & 2
          •    Break
          •    Project 3 & 4
          •    Explaining More Code
          •    Project 5 & 6
          •    Q&A + Free Project Time




Saturday, April 6, 13
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
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
Saturday, April 6, 13
Arduino Shields
          
 PCB
 
      
   
   Built Shield
 
   
   Inserted
          Shield




Saturday, April 6, 13
Arduino Shields

          
     Micro SD

   
   MP3 Trigger
                                            
   
   Joystick




Saturday, April 6, 13
ArduSensors - ‘Mini Shields’




Saturday, April 6, 13
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.
                                             colors



Saturday, April 6, 13
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, buttons




Saturday, April 6, 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
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
What’s a Breadboard?




Saturday, April 6, 13
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
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
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
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
          caps




Saturday, April 6, 13
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
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
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
   rising




Saturday, April 6, 13
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/software

Saturday, April 6, 13
Installing Drivers for Mac
         The first time you plug a Leonardo into a Mac, the
         "Keyboard Setup Assistant" will launch. There's
         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
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 Next


Saturday, April 6, 13
Installing Drivers for Windows




Saturday, April 6, 13
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




Saturday, April 6, 13
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




Saturday, April 6, 13
Installing Drivers for Windows




Saturday, April 6, 13
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 Anyway




Saturday, April 6, 13
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
Saturday, April 6, 13
Saturday, April 6, 13
Board Type




Saturday, April 6, 13
Serial Port / COM Port




Saturday, April 6, 13
Which COM/Serial Port?
          Mac: /dev/tty.usbmodemfd131

                         Interchangeable #:

          Windows: COM#
          Device Manager:

          Start>Control
          Panel>System &
          Security>Device
          Manager>Ports
Saturday, April 6, 13
Circuit 1: Basic Blink




Saturday, April 6, 13
How to get the sketch:



           Go to File>Examples>01.Basics>Blink




Saturday, April 6, 13
39
Saturday, April 6, 13
Parts of the Sketch




Saturday, April 6, 13
void setup() {}




                                          41
Saturday, April 6, 13
void loop ( ) { }




Saturday, April 6, 13
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

Saturday, April 6, 13
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
Example of Comment:




Saturday, April 6, 13
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 circuit




Saturday, April 6, 13
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
            Arduino




Saturday, April 6, 13
Downloading Code

          https://github.com/Qtechknow/
            Arduino-Code/zipball/master/




Saturday, April 6, 13
Circuit 2: Analog Reading




Saturday, April 6, 13
Saturday, April 6, 13
Break




Saturday, April 6, 13
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
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 5V
Saturday, April 6, 13
Parts for Circuit 3:

          Arduino Leonardo
          Breadboard
          Pushbutton (2)
          LED (2)
          Resistor - 10K Ohm (2)
          Resistor - 330 Ohm (2)
          Jumper Wires


Saturday, April 6, 13
Circuit 3: Buttons




Saturday, April 6, 13
`




Saturday, April 6, 13
Saturday, April 6, 13
Semicolons

               Semicolons are needed after every line
               of code, except for void setup(), void
               loop(), and a few others




Saturday, April 6, 13
Operators

                             The equals sign

                        = is used to assign a value

                    == is used to compare values



Saturday, April 6, 13
Operators


                        && is “and”

                         || is “or”




Saturday, April 6, 13
Variables

                        Basic variable types:

                          Boolean (on or off)
                          Integer (a number)
                          Character (a letter)
                    String (a phrase/many letters)


Saturday, April 6, 13
Declaring Variables

                            Boolean: boolean
                             variableName;

                        Integer: int variableName;

                  Character: char variableName;
                     String: stringName [ ];
Saturday, April 6, 13
Assigning Variables

                  Boolean: variableName = true;
                    or variableName = false;




Saturday, April 6, 13
Assigning Variables

                  Boolean: variableName = true;
                    or variableName = false;
                     Integer: variableName =
                              32767;
                   or variableName = -32768;



Saturday, April 6, 13
Assigning Variables

                  Boolean: variableName = true;
                    or variableName = false;
                     Integer: variableName =
                              32767;
                   or variableName = -32768;
                  Character: variableName = ‘A’;
                         or stringName =
                          “Deezmaker”;
Saturday, April 6, 13
Variable Scope
                        Where you declare your variables
                                   matters




Saturday, April 6, 13
Circuit 4: ArduSensor + LED




Saturday, April 6, 13
Circuit 4: ArduSensor+LED




Saturday, April 6, 13
Saturday, April 6, 13
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
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 CAPS

Saturday, April 6, 13
If Statements
                        if ( this is true ) { do this; }




Saturday, April 6, 13
If
                        if ( this is true ) { do this; }




Saturday, April 6, 13
Conditional
                        if ( this is true ) { do this; }




Saturday, April 6, 13
Action
                        if ( this is true ) { do this; }




Saturday, April 6, 13
Else
                        else { do this; }




Saturday, April 6, 13
Basic Repetition

  for (int count = 0; count<10; count++)
  {
  //for action code goes here
  //this could be anything
  }




Saturday, April 6, 13
Basic Repetition

  for (int count = 0; count<10; count++)
  {
  //for action code goes here
  }




Saturday, April 6, 13
Basic Repetition

  for (int count = 0; count<10; count++)
  {
  //for action code goes here
  }




Saturday, April 6, 13
Basic Repetition

  for (int count = 0; count<10; count++)
  {
  //for action code goes here
  }




Saturday, April 6, 13
Basic Repetition

  for (int count = 0; count<10; count++)
  {
  //for action code goes here
  }




Saturday, April 6, 13
Basic Repetition

  for (int count = 0; count<10; count++)
  {
  //for action code goes here
  }




Saturday, April 6, 13
Circuit 5: LED Bounce




Saturday, April 6, 13
Saturday, April 6, 13
Saturday, April 6, 13
Circuit 6: Meter




Saturday, April 6, 13
Saturday, April 6, 13
Saturday, April 6, 13
Q&A and Project time




Saturday, April 6, 13

Contenu connexe

Dernier

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Dernier (20)

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 

En vedette

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

En vedette (20)

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 

Intro to Arduino at Deezmaker by Qtechknow

  • 1. Intro to Arduino Class Deezmaker 3D Printer Store and Hackerspace Taught by Quin 4/6/13 Saturday, April 6, 13
  • 2. Thank you to SparkFun for sharing the original presentation! Saturday, April 6, 13
  • 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. Schedule • Getting started with Arduino and electronics • Project 1 & 2 • Break • Project 3 & 4 • Explaining More Code • Project 5 & 6 • Q&A + Free Project Time Saturday, April 6, 13
  • 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. 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
  • 8. Arduino Shields PCB Built Shield Inserted Shield Saturday, April 6, 13
  • 9. Arduino Shields Micro SD MP3 Trigger Joystick Saturday, April 6, 13
  • 10. ArduSensors - ‘Mini Shields’ Saturday, April 6, 13
  • 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. colors Saturday, April 6, 13
  • 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, buttons Saturday, April 6, 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. 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
  • 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. 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. 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. 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 caps Saturday, April 6, 13
  • 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. 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. 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 rising Saturday, April 6, 13
  • 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/software Saturday, April 6, 13
  • 24. Installing Drivers for Mac The first time you plug a Leonardo into a Mac, the "Keyboard Setup Assistant" will launch. There's 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. 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 Next Saturday, April 6, 13
  • 26. Installing Drivers for Windows Saturday, April 6, 13
  • 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 Next Saturday, April 6, 13
  • 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 OK Saturday, April 6, 13
  • 29. Installing Drivers for Windows Saturday, April 6, 13
  • 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 Anyway Saturday, April 6, 13
  • 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
  • 35. Serial Port / COM Port Saturday, April 6, 13
  • 36. Which COM/Serial Port? Mac: /dev/tty.usbmodemfd131 Interchangeable #: Windows: COM# Device Manager: Start>Control Panel>System & Security>Device Manager>Ports Saturday, April 6, 13
  • 37. Circuit 1: Basic Blink Saturday, April 6, 13
  • 38. How to get the sketch: Go to File>Examples>01.Basics>Blink Saturday, April 6, 13
  • 40. Parts of the Sketch Saturday, April 6, 13
  • 41. void setup() {} 41 Saturday, April 6, 13
  • 42. void loop ( ) { } Saturday, April 6, 13
  • 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 author Saturday, April 6, 13
  • 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
  • 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 circuit Saturday, April 6, 13
  • 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 Arduino Saturday, April 6, 13
  • 48. Downloading Code https://github.com/Qtechknow/ Arduino-Code/zipball/master/ Saturday, April 6, 13
  • 49. Circuit 2: Analog Reading Saturday, April 6, 13
  • 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. 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 5V Saturday, April 6, 13
  • 54. Parts for Circuit 3: Arduino Leonardo Breadboard Pushbutton (2) LED (2) Resistor - 10K Ohm (2) Resistor - 330 Ohm (2) Jumper Wires Saturday, April 6, 13
  • 58. Semicolons Semicolons are needed after every line of code, except for void setup(), void loop(), and a few others Saturday, April 6, 13
  • 59. Operators The equals sign = is used to assign a value == is used to compare values Saturday, April 6, 13
  • 60. Operators && is “and” || is “or” Saturday, April 6, 13
  • 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. Declaring Variables Boolean: boolean variableName; Integer: int variableName; Character: char variableName; String: stringName [ ]; Saturday, April 6, 13
  • 63. Assigning Variables Boolean: variableName = true; or variableName = false; Saturday, April 6, 13
  • 64. Assigning Variables Boolean: variableName = true; or variableName = false; Integer: variableName = 32767; or variableName = -32768; Saturday, April 6, 13
  • 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. Variable Scope Where you declare your variables matters Saturday, April 6, 13
  • 67. Circuit 4: ArduSensor + LED Saturday, April 6, 13
  • 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. 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 CAPS Saturday, April 6, 13
  • 72. If Statements if ( this is true ) { do this; } Saturday, April 6, 13
  • 73. If if ( this is true ) { do this; } Saturday, April 6, 13
  • 74. Conditional if ( this is true ) { do this; } Saturday, April 6, 13
  • 75. Action if ( this is true ) { do this; } Saturday, April 6, 13
  • 76. Else else { do this; } Saturday, April 6, 13
  • 77. Basic Repetition for (int count = 0; count<10; count++) { //for action code goes here //this could be anything } Saturday, April 6, 13
  • 78. Basic Repetition for (int count = 0; count<10; count++) { //for action code goes here } Saturday, April 6, 13
  • 79. Basic Repetition for (int count = 0; count<10; count++) { //for action code goes here } Saturday, April 6, 13
  • 80. Basic Repetition for (int count = 0; count<10; count++) { //for action code goes here } Saturday, April 6, 13
  • 81. Basic Repetition for (int count = 0; count<10; count++) { //for action code goes here } Saturday, April 6, 13
  • 82. Basic Repetition for (int count = 0; count<10; count++) { //for action code goes here } Saturday, April 6, 13
  • 83. Circuit 5: LED Bounce Saturday, April 6, 13
  • 89. Q&A and Project time Saturday, April 6, 13