Arduino the micro controller we use is in essence a small computer designed to allow artists to work with hardware and interactivity.
1/Introduction
Arduino is an open source physical computing platform based on a simple input/output (I/O) board and a development environment that implements the wiring language . Arduino can be used to develop standalone interactive objects or can be connected to software on your computer (such as Flash, Processing, VVVV, or Max/MSP).
The specific field of Interaction Design involved with Arduino is Physical Computing (or Physical Interaction Design).
What Is Physical Computing?
Physical Computing uses electronics to prototype new materials for designers and artists. It involves the design of interactive objects that can communicate with humans using sensors and actuators controlled by a behavior implemented as software running inside a micro-controller (a small computer on a single chip).
The Arduino Platform
Arduino is composed of two major parts: the Arduino board, which is the piece of hardware you work on when you build your objects; and the Arduino IDE, the piece of software you run on your computer. You use the IDE to create a sketch (a little computer program) that you upload to the Arduino board. The sketch tells the board what to do.
Anatomy of an Interactive Device
All of the objects we will build using Arduino follow a very simple pattern that we call the “Interactive Device”. The Interactive Device is an electronic circuit that is able to sense the environment using sensors (electronic components that convert real-world measurements into electrical signals). The device processes the information it gets from the sensors with behaviour that’s implemented as software. The device will then be able to interact with the world using actuators, electronic components that can convert an electric signal into a physical action.
The Arduino Hardware
The Arduino board is a small micro-controller board, which is a small circuit (the board) that contains a whole computer on a small chip (the micro-controller). The arduino team placed all the components that are required for this micro-controller to work properly and to communicate with your computer.
14 Digital IO pins (pins 0–13)
These can be inputs or outputs, which is specified by the sketch you create in the IDE.
6 Analogue In pins (pins 0–5)
These dedicated analogue input pins take analogue values (i.e., voltage readings from a sensor) and convert them into a number between 0 and 1023.
6 Analogue Out pins (pins 3, 5, 6, 9, 10, and 11)
These are actually six of the digital pins that can be reprogrammed for analogue output using the sketch you create in the IDE.
NICE INTRO TO ARDUINO
This Arduino comic available on PDF by Jody Culkin gives you a good
overview of what Arduino is and why you might like to use it
GETTING STARTED WITH ARDUINO
http://arduino.cc/en/Guide/HomePage
Download and install software. Check
HELLO WORLD
LED positive (long leg) goes into pin 13 on digital side of board. Short leg (negative) goes to ground.
To make sure Arduino is talking to computer - check you have correct board selected. Go to tools/board
and check that you selected the right board.
An LED (LIGHT EMITTING DIODE ) is a small electronic component a bit like a lightbulb , but it is more efficient and requires
lower voltages to operate
Once the LED is connected you need to tell the Arduino what to do. This is done through code that is a list of instructions we
give the micro-controller to make it do what we want.
The first sketch you will run is blink.
Remember to verify (tick mark) -and then upload(arrow). LED should blink. If you have problems
you may have to adjust the serial port. Try different serial ports if you have a problem getting the board to talk to the
computer.
The Arduino Software (IDE) uses the concept of a sketchbook: a standard place to store your programs (or sketches). The sketches in your sketchbook can be opened from the File > Sketchbook menu or from theOpen button on the toolbar. The first time you run the Arduino software, it will automatically create a directory for your sketchbook. You can view or change the location of the sketchbook location from with thePreferences dialog.
To sum up, this program does this:
>> LED connected to digital pin 13
const int means that LED is an integer number that cannot be changed ( ie a constant ) whose
value is set to 13 .Its telling arduino to write the number 13 every time the constant LED appears.
We are using the command to specify that the LED we are blinking is connected to pin 13.
Every Arduino program has two functions . Functions are part of a computer program that run specific commands. Functions have unique names and are called when needed . The necessary functions in the Arduino program are called setup() and loop(). These functions need to be declared which means you need to tell the Arduino what these functions will do.
» Turns pin 13 into an output (just once at the beginning)
(pinMode tells arduino how to configure a certain pin. Digital pins can be either INPUTS or OUTPUTS.
In this case we need an output pin to control our LED.
» Enters a loop
» Switches on the LED connected to pin 13
As the comment says digitalWrite ()is able to turn on (or off) any pin that has been configured as the OUTPUT.
» Waits for a second
» Switches off the LED connected to pin 13
» Waits for a second
» Goes back to beginning of the loop
What is Electricity
OHMS LAW
Building a basic circuit
We are going to build a very simple circuit we are going to use a small LED CONNECTED TO A BUTTON & when you press the button the LED comes on. Its a very simple electronic circuit that is designed to help you understand all the parts that make a basic circuit.
What is an LED An LED is a small source of light its like a light bulb but much more efficient because it doesn't generate that much heat because its an electronic component based on a semiconductor. LEDs are very convenient for us because it works at a small voltage so they can be powered from a battery or the voltage you get from an arduino board.
So What is a circuit? A circuit is a series of electronic components like this LED or this button connected together using wire. Electricity can flow through the components and each component is able to transform the electricity into something else like light like the LED does or for example the switch is a component that can open & close a circuit
when you press on it. This particular button keeps the circuit open until I press the button & then it closes the circuit, closing the circuit is a little bit like opening a tap you let the electricity flow through the button.
Ohms Law
Electricity you can imagine is like water and the wires we are using are the pipes so the source of electricity is essentially the equivalent of something that pushes water into the pipes.So the first circuit that we build is going to have a source of electricity pushing the current through the wires. A number of wires that connect to the button , then the button will open & close the circuit & when the circuit is closed the current will flow through the LED .
Then we will use another component we have here called a resistor. What happens is the voltage from our battery is too high for the LED we are using. We will be using a source of electricity that operates at 5volts, the standard voltage at which the arduino board operates but this LED only needs about 1,7volts . So we use a resistor to limit the amount of current that flows through the LED keeping it at an optimum amount of voltage & current.
Breadboard
How do we make the connection ,what happens with circuits is you can take wires & you can wrap them around but thats not very practical if you want to do a lot of experimentation, if you want to move components around or try different around or try different circuits its not the best idea so we use a breadboard. The breadboard provides a set of pre arranged connections & each one of those holes is connected underneath with a metallic spring
Actuator
The LED acts as an actuator turning electricity into light
Building the circuit
Place the button on the breadboard
Place a resistor between one leg of the button and (Red) power line on the Breadboard
Connect the (Anode- Longer leg of LED) between other leg of the push button
& connect the cathode (short leg of LED) to ground on the Breadboard
Connect 5volts on the arduino to Power (Red line on the Breadboard)
Connect GND (Ground) on arduino to ground on Breadboard
Now that you have got the basics of electricity under your belt , its time to move on to controlling things with your Arduino.
Digital INPUT/OUTPUT
Digital Pins
The Arduino’s digital pins read only two states : when there is voltage on an input pin and when there is not. This kind of input is usually called digital ( or sometimes binary for two state). These states are commonly referred to as HIGH and LOW. HIGH is the same as saying “there is voltage here!’” and LOW means “there is no voltage on this pin!” When you turn an OUTPUT pin HIGH using a command called digitalWrite(), you are turning it on. Measure the voltage between the pin and ground and you will get 5volts. When you turn an OUTPUT PIN LOW you turn it off.
The Arduino’s digital pins can act as both inputs and outputs. In the code you will configure them depending on what you want their function to be. When the pins are outputs you can turn on components like LED,s . If you configure the pins as inputs ,you can check if a switch/push button is being pressed or not. Since pins 0 and 1 are used for communicating with the computer , it’s best to start with pin 2.
Connections
Wire up your breadboard to Arduino’s 5V AND GROUND CONNECTIONS like the previous
example.
Attached the (cathode) short leg of the red LED ground and the long leg to digital pin 13 on the arduino
Place the pushbutton on the breadboard.
Attach one side of the pushbutton to power and the other side to digital pin 2 on the Arduino.
You’ll also need to add a 10k-ohm resistor from ground to the switch pin that connects to the Arduino. That pull down resistor connects the pin to ground when the switch is open, so it reads LOW when there is no voltage coming through the switch.
KEEP LED IN PIN 13 + run EXAMPLES/DIGITAL/ BUTTON
The code
Every Arduino program has two functions . Functions are part of a computer program that run specific commands. Functions have unique names and are called when needed . The necessary functions in the Arduino program are called setup() and loop(). These functions need to be declared which means you need to tell the Arduino what these functions will do.
In this program you are going to create a variable before you get into the main part of the program. Variables are names you give to places in the Arduino’s memory so you can keep track of what is happening. These values can change depending on your programs instructions. Variables names should be descriptive of what they are storing. For example a variable named buttonState tells you what it stores the state of the switch
To create a variable you need to declare what type it is . The data type int will hold a whole number (also called an integer). thats any number without a decimal point. When you declare
a variable , you usually give it an initial value as well. The declaration of the variable as every statement must end with a semicolon(;).
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
The setup() runs once , when the Arduino is first powered on.
This is where you configure the digital pins to be either inputs or outputs using a function called pinMode (). The pin connected to ledPin is the OUTPUT and the pin connected to buttonPin is the INPUT.
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
The loop() runs continuously after the setup () has completed. The loop is where you will check for voltage on the inputs, and turn outputs on and off. The check the voltage level on the
digital input , you use function digitalRead() that checks the chosen pin for voltage. To know
what pin to check digitalRead( )expects an argument.
Arguments are information you pass to functions telling them how they should do there job.For example digitalRead() is going to check the state of the buttonPin and store the value in the buttonState variable. If there is voltage on the pin when digitalRead () is called the button State variable will get the value HIGH (or 1). If there is not voltage on the buttonPin then buttonState will get a value LOW (or 0).
An if () statement in programming compares two things and determines whether the comparison is true or false. Then it performs actions you tell it to do.
digitalWrite() is the command that allows you to send 5V or 0volts to an output pin. digitalWrite() takes two arguments : what pin to control and what value to set the pin HIGH or
LOW. Here if the we want to turn the LED on inside the if statement we use the code like this.
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
}
You have told the Arduino what to do when the switch is open. Now you define what happens when the switch is closed. The if() statement has an optional else that allows for something to happen if the original statement is not met. Since you checked to see if the switch was HIGH
, we write code for the LOW condition after the else.
To turn the LED off we write
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}
Testing Serial Communication
Hook up using breadboard +10 k resistor
Serial Communication
Test your switch circuit
WHEN switch is closed the code should output a 1. We are using digital side of board and are dealing with on off states (ie 0 or 1).
Serial communication allows Arduino to communicate with other software such as
Processing, Pure Data or Max Msp. These programs allow extra functionality if we wish to play
back media files such as video or sound.