Module 3a: Introduction to Arduino


Module 3a: Introduction to Arduino

Goal of this Module: Introduce students to the basics of Arduino
Module 3a: Introduction to Arduino Document Download

Module: Introduction to Arduino
Arduino Kit: 
  • Arduino
  • Standard A-B USB Cable
  • breadboard
  • jumper wires
  • LEDs RYBG
  • 3 volt battery
  • coin holder
  • button
  •   

    Download Arduino Software for Free

    breadboardDoc1

    Arduino Basics
     
    Arduino2

    What is on an Arduino
      
    breadboardDoc3

    Set up
     
    breadboardDoc4

    Adding LED
     
    breadboardDoc5

    Edit Code
     
    breadboardDoc5

    Multiple LEDs
     
    breadboardDoc5

    Photoresistor
     
    breadboardDoc5

    /* 
    Adapted from
    http://playground.arduino.cc/Learning/PhotoResistor
    Simple test of the functionality of the photo resistor
    
    Connect the photoresistor one leg to pin 0, and pin to +5V
    Connect a resistor (around 10k is a good value, higher
    values gives higher readings) from pin 0 to GND. 
    
    ----------------------------------------------------
    
               PhotoR     10K
     +5     o---/\/\/--.--/\/\/---o GND
                       |
     Pin A0 o-----------
    
    ----------------------------------------------------
    */
    
    int lightPin = A0;  // the pin for photoresistor (input)
    
    void setup()
    {
        Serial.begin(9600);  //Begin serial communication
        pinMode( lightPin, INPUT );
    }
    
    void loop()
    {
        Serial.println(analogRead(lightPin)); //Write the value of the photoresistor to the serial monitor.
        delay(10); //short delay for faster response to light.
    }
    Serial Monitor
     
    breadboardDoc5

    Set up
     
    breadboardDoc5

    /* 
    Adapted from
    http://playground.arduino.cc/Learning/PhotoResistor
    Simple test of the functionality of the photo resistor
    
    Connect the photoresistor one leg to pin 0, and pin to +5V
    Connect a resistor (around 10k is a good value, higher
    values gives higher readings) from pin 0 to GND. 
    
    ----------------------------------------------------
    
               PhotoR     10K
     +5     o---/\/\/--.--/\/\/---o GND
                       |
     Pin A0 o-----------
    
    ----------------------------------------------------
    */
    
    int lightPin = A0;  //define a pin for Photo resistor (input)
    int ledPin = 13; // the pin for the led (output)
    
    void setup()
    {
        Serial.begin(9600);  //Begin serial communication
        pinMode( lightPin, INPUT );
        pinMode( ledPin, OUTPUT );
    }
    
    void loop()
    {
        int lightValue = analogRead( lightPin );
        Serial.println( lightValue ); //Write the value of the photoresistor to the serial monitor.
    
        // if there is not enough light
        if ( lightValue < 400 )
           // turn on the LED
           digitalWrite( ledPin, HIGH );
        else
           // otherwise, turn it off
           digitalWrite( ledPin, LOW );
    
        delay(10); //short delay for faster response to light
    }
    Ohms Law
     
    breadboardDoc5