Arduino: Zero to Virtual Prototyping in Seven Hours
Overview of Class
This class provides an introduction to Arduino, covering the following topics:
- Getting Started: Installation, Applications, and Materials
- Electrical Concepts: Components, Ohm's Law, Input and Output, Analog and Digital
- Programming Basics
- Serial Communication Basics: Troubleshooting and Debugging
- Virtual Prototyping: Schematics and PCB Layout in Fritzing
Arduino Board
The Arduino board, nicknamed "Strong Friend," was created in Ivrea, Italy, in 2005 by Massimo Banzi and David Cuartielles. It is an open-source hardware platform featuring an Atmel processor. Coding for Arduino is accessible using languages like C++, Processing, ModKit, and MiniBloq.
The core Arduino team includes David Cuartielles and Massimo Banzi, along with Gianluca Martino.
Getting Started
Installation
Requires Arduino IDE (v.22), Fritzing, Java, and necessary drivers.
Materials
Includes SIK Guide, handouts on Analog I/O, Digital I/O, Serial Communication, and Fritzing.
Applications
Key software applications used are:
- Arduino IDE for programming the board.
- Fritzing for creating Printed Circuit Boards (PCBs).
- Modkit, a combination of Arduino and Scratch for visual programming.
Fritzing
Fritzing is an open-source virtual electrical prototyping project that began in 2007 at the Interaction Design Lab at the University of Applied Science Potsdam, Germany. It aims to help users document, share, and manufacture their open-source prototypes.
Arduino Shields
Arduino Shields are add-on boards that can be plugged into an Arduino board to extend its functionality. Examples include:
- Micro SD Shield: For data logging or storing files.
- MP3 Trigger Shield: For playing audio files.
- Joystick Shield: For game input or control.
Fritzing can be used to design Printed Circuit Boards (PCBs) and visualize how shields are built and inserted.
MODKIT, Alpha & Beta
MODKIT is a graphical user interface designed for intuitive coding of Arduino. Developed by Ed Baafi and Collin Reisdorf, it consists of two main components: an Online Editor and a downloadable application. The download allows for uploading code to the Arduino board, while the programming environment provides a visual interface for creating programs.
Components
A variety of electronic components can be used with Arduino:
Name | Type | Function | Notes |
---|---|---|---|
Button | Digital Input | Closes or opens a circuit | Polarized, needs resistor |
Trimpot | Analog Input | Variable resistor | Variable resistor |
Photoresistor | Analog Input | Variable resistor | Responds to light levels |
Relay | Digital Output & Input | Switches between circuits | Used to control larger voltages |
Temp Sensor | Analog Input | Variable resistor | Measures temperature |
Flex Sensor | Analog Input | Variable resistor | Bends one way only |
Soft Trimpot | Analog Input | Variable resistor | Be careful of shorts |
RGB LED | Dig. & Analog Output | Outputs 16,777,216 different colors | "Ooh... So pretty." |
Ohm's Law
Ohm's Law describes the direct relationship between Voltage (V), Current (I), and Resistance (R) in a circuit. The formulas are:
- V = I * R
- I = V / R
- R = V / I
Importance of Voltage
Voltage allows electricity to travel through circuit components. The voltage of the power source must be greater than the total voltage drop across the circuit for electricity to flow from power to ground.
Importance of Current
Current is the aspect of electricity that performs physical work or movement.
Importance of Continuity
Continuity is crucial for ensuring portions of circuits are connected. It is considered the simplest and possibly most important setting on a multimeter.
What's a Breadboard?
A breadboard is a highly useful tool for engineers and makers. Key points to remember:
- It is easier to use than soldering.
- Many of the small holes are internally connected; understanding these connections is important.
- Breadboards can sometimes break.
Analog and Digital Signals
All Arduino signals are either Analog or Digital. Computers, including Arduino, understand only Digital signals. It is important to recognize the difference, as Analog signals require an Analog-to-Digital Conversion (ADC).
Output
Output refers to any signal exiting an electrical system. Most physical computing systems utilize some form of output.
Arduino outputs are always Digital (On or Off). To output a digital signal, use the command: digitalWrite(pinNumber, value);
where value
is HIGH or LOW.
To output a signal that simulates analog behavior, use: analogWrite(pinNumber, value);
where value
is a number from 0 to 255.
Using a digital signal that simulates analog behavior is called Pulse Width Modulation (PWM). PWM is available on Arduino pins #3, #5, #6, #9, #10, and #11.
Even when using PWM, the output is fundamentally digital. The Arduino pin rapidly switches between HIGH and LOW to simulate intermediate values.
- PWM Signal @ 25% duty cycle
- PWM Signal @ 75% duty cycle
- PWM Signal rising: Illustrates how the PWM duty cycle can be varied.
The relationship between PWM value (0-255) and the effective voltage is linear, with 0 corresponding to 0V and 255 corresponding to approximately 5V.
Input
Input is any signal entering an electrical system. Both digital and analog sensors serve as forms of input. Input can also come from keyboards, mice, infrared sensors, biometric sensors, or direct voltage from a circuit.
Analog Input
Connect analog inputs to Arduino using Analog Pins #0 through #5. To read an analog value, use the command: analogRead(pinNumber);
. Analog input on Arduino typically ranges from 0 to 1023.
Analog Sensors
Examples of analog sensors and their readings include:
- Mic: Reads Volume (Decibels), outputs Voltage.
- Photoresistor: Reads Light (Photons), outputs Voltage.
- Potentiometer: Reads Dial Position, outputs Voltage.
- Temp Sensor: Reads Temperature (Celsius), outputs Voltage.
- Flex Sensor: Reads Bend, outputs Resistance (which can be converted to Voltage).
- Accelerometer: Reads Motion/Tilt/Acceleration, outputs Voltage.
Digital Input
Connect digital inputs to Arduino using Digital Pins #0 through #13 (note that pins #0 and #1 are also used for serial communication). Digital input requires setting the pin mode using the command: pinMode(pinNumber, INPUT);
(ensure INPUT is in uppercase). To read a digital value, use: digitalRead(pinNumber);
. Digital input values are binary: HIGH (On) or LOW (Off).
Digital Sensors
Digital sensors are generally more straightforward than analog ones. Regardless of the specific sensor, there are typically only two states: On or Off. The signal is always either HIGH (On) or LOW (Off). For a HIGH signal on an Arduino Uno, the voltage is typically slightly less than 5V, while a LOW signal is 0V.
Further Information
For more details and resources, visit:
SparkFun
6175 Longbow Drive, Suite 200
Boulder, Colorado 80301