Difference between revisions of "Arduino tutorial"

From Open Garage Wiki
Jump to: navigation, search
(Tutorial)
 
(5 intermediate revisions by one user not shown)
Line 15: Line 15:
  
 
==Tutorial==
 
==Tutorial==
 +
 +
Workshop overview
 +
* 3 x 1 hour (Arduino & LED; breadboard & buttons; analog & USB), 2 5 minute breaks
 +
* During a streaming tutorial, Wouter supports, ask Qs in chat
  
 
<span style="background-color: yellow;">Explanation: Anthony gives tour of hardware</span>
 
<span style="background-color: yellow;">Explanation: Anthony gives tour of hardware</span>
 +
* About Arduino & Raspberry Pi
 +
* Computer basics (16Mhz, 2kb RAM, 32kb ROM)
 +
* Open hardware & alternatives
 +
* Shields etc
 +
* Community
 +
* Tour of the hardware
 +
* Tour of the kit
  
 
=== Install ===
 
=== Install ===
Line 42: Line 53:
 
** It has its own symbol, ...---..., dot dot dot dash dash dash dot dot dot
 
** It has its own symbol, ...---..., dot dot dot dash dash dash dot dot dot
 
** In Morse, a dash is 3 times as long as a dot, the delay between dashes/dots is as long as a dot. Symbols are separated with a delay that is as long as a dash
 
** In Morse, a dash is 3 times as long as a dot, the delay between dashes/dots is as long as a dot. Symbols are separated with a delay that is as long as a dash
 +
 +
<gallery>
 +
File:LED_pin_13.png|An LED on pin 13
 +
</gallery>
  
 
<span style="background-color: yellow;">Intermezzo: Anthony explains the breadboard, basics of resistors for LEDs, buttons and pull-up/pull-down resistors.</span>
 
<span style="background-color: yellow;">Intermezzo: Anthony explains the breadboard, basics of resistors for LEDs, buttons and pull-up/pull-down resistors.</span>
Line 48: Line 63:
  
 
* Add an LED on pin 12 and animate both LEDs (you'll need to move to the breadboard to add a resistor!)
 
* Add an LED on pin 12 and animate both LEDs (you'll need to move to the breadboard to add a resistor!)
 +
 +
<gallery>
 +
File:Breadboard.jpg|Breadboard
 +
File:Proper_breadboard_use.png|Proper breadboard use
 +
File:An_LED_on_pin_12.png|An LED on pin 12
 +
</gallery>
  
 
=== Basics of digital inputs: Buttons ===
 
=== Basics of digital inputs: Buttons ===
Line 58: Line 79:
  
 
<span style="background-color: yellow;">Intermezzo: Anthony talks about analog inputs, outputs and communicating data to the computer.</span>
 
<span style="background-color: yellow;">Intermezzo: Anthony talks about analog inputs, outputs and communicating data to the computer.</span>
 +
 +
<gallery>
 +
File:Pull_down_button.png|Button with pull-down resistor
 +
File:Pull_up_button.png|Button with pull-up resistor
 +
</gallery>
  
 
=== "Analog" output ===
 
=== "Analog" output ===
  
* Change the LED to PWM (File > Example > Basics > Fade)
+
* Change the LED to PWM (File > Example > Analog > Fading)
  
 
=== Analog input ===
 
=== Analog input ===
Line 71: Line 97:
 
* Replace the photoresistor and pull-down resistor with a potentiometer
 
* Replace the photoresistor and pull-down resistor with a potentiometer
 
* Control the PWM LED brightness with the potentiometer
 
* Control the PWM LED brightness with the potentiometer
 +
 +
<gallery>
 +
File:Photoresistor.png|Photoresistor as analog input
 +
</gallery>
  
 
=== MOAR! ===
 
=== MOAR! ===
Line 78: Line 108:
 
* Find a project in the Arduino book and make it!
 
* Find a project in the Arduino book and make it!
 
* Take a sensor, or a motor, or a display, Google its symbol/number/registration together with the term Arduino and make something!
 
* Take a sensor, or a motor, or a display, Google its symbol/number/registration together with the term Arduino and make something!
 
=== Circuits ===
 
 
<gallery>
 
File:LED_pin_13.png|An LED on pin 13
 
File:An_LED_on_pin_12.png|An LED on pin 12
 
File:Breadboard.jpg|Breadboard
 
File:Proper_breadboard_use.png|Proper breadboard use
 
File:Pull_down_button.png|Button with pull-down resistor
 
File:Pull_up_button.png|Button with pull-up resistor
 
File:Photoresistor.png|Photoresistor as analog input
 
</gallery>
 

Latest revision as of 20:08, 13 September 2021

The goal of this tutorial is very generic for any beginner, you'll learn all the basics to use digital, analog and serial inputs and outputs on the Arduino, allowing you to transfer your digital skills into the physical world. A dedicated student will be able to go through all these steps in about two hours.

Contents

Parts needed

  • Arduino (we prefer to use the original UNO version, which is most common)
  • Internet connected computer on which you can install the Arduino IDE (Windows, Mac, Linux)
  • USB B cable
  • LED
  • Breadboard
  • Collection of male-male breadboard wires
  • 220 ohm resistor
  • Button
  • 10K ohm resistor
  • Potentiometer

Tutorial

Workshop overview

  • 3 x 1 hour (Arduino & LED; breadboard & buttons; analog & USB), 2 5 minute breaks
  • During a streaming tutorial, Wouter supports, ask Qs in chat

Explanation: Anthony gives tour of hardware

  • About Arduino & Raspberry Pi
  • Computer basics (16Mhz, 2kb RAM, 32kb ROM)
  • Open hardware & alternatives
  • Shields etc
  • Community
  • Tour of the hardware
  • Tour of the kit

Install

Parts: Computer, Arduino, USB B cable, internet

  • Connect Arduino with USB B cable to computer
    • Green Power LED turns on
    • Default factory setting: orange LED near pin 13 blinks
  • Install Arduino IDE from http://arduino.cc/en/main/software

Basics of digital output: Blinking LED

A blinking LED is the Hello World of electronics.

Parts: LED

  • Load the blinking LED example program in the Arduino IDE (File > Examples > Basics > Blink)
  • Verify & Upload the program to the Arduino
    • Arduino not found? Under "Tools" in the main menu: check whether board (Arduino Uno) and port (dependent on your computer's settings) is correctly configured
  • Add an LED between pin 13 (long leg) and GND (short leg)
  • Change the speed of the blinking LED
  • Make "SOS" with the blinking LED
    • In Morse code, SOS stands for "Save Our Souls"
    • It has its own symbol, ...---..., dot dot dot dash dash dash dot dot dot
    • In Morse, a dash is 3 times as long as a dot, the delay between dashes/dots is as long as a dot. Symbols are separated with a delay that is as long as a dash

Intermezzo: Anthony explains the breadboard, basics of resistors for LEDs, buttons and pull-up/pull-down resistors.

Parts: LED, breadboard, wires, 220ohm resistor

  • Add an LED on pin 12 and animate both LEDs (you'll need to move to the breadboard to add a resistor!)

Basics of digital inputs: Buttons

Parts: Button, 10kohm resistor

  • Add a button with a pull-down resistor to your existing LED project, see http://www.arduino.cc/en/Tutorial/Button with code in (File > Examples > Digital > Button)
  • Let your LED on pin 12 turn on when the button is pressed.
  • Change the pull-down resistor circuit to a pull-up resistor circuit and change the program so that the button example works correctly again.

Intermezzo: Anthony talks about analog inputs, outputs and communicating data to the computer.

"Analog" output

  • Change the LED to PWM (File > Example > Analog > Fading)

Analog input

Parts: photoresistor, potentiometer

  • Keep the PWM LED and replace the button with a photoresistor, with Files > Examples > Basic > AnalogReadSerial
  • When the program is running, open the "Serial Monitor" in the Arduino IDE to monitor photoresistor values being sent over serial USB connection
  • Replace the photoresistor and pull-down resistor with a potentiometer
  • Control the PWM LED brightness with the potentiometer

MOAR!

What will you build next?

  • Find a project in the Arduino book and make it!
  • Take a sensor, or a motor, or a display, Google its symbol/number/registration together with the term Arduino and make something!