The Arduino UNO is a spectacular micro controller based on the Atmega328 chip set. It has revolutionized open source access to inexpensive microcontrollers. While the Arduino is a tremendous platform and the provided code and IDE (Integrated Development Environment) are wonderful this book will focus more on using MAX MSP and Jitter through the Arduino communicating through MAXUINO and Firmata.
Arduino is an open-source physical computing platform based on an i/o board and a development environment that implements the Processing/ Wiring language.
Arduino can be used to develop stand-alone interactive objects or can be connected to software on your computer (e.g. Flash, Processing, MaxMSP).
This open-source IDE can be downloaded for free (currently for Mac OS X, Windows, and Linux).
Microcontroller
|
ATmega328
|
Operating Voltage
|
5V
|
Input Voltage (recommended)
|
7-12V
|
Input Voltage (limits)
|
6-20V
|
Digital I/O Pins
|
14 (of which 6 provide PWM output)
|
Analog Input Pins
|
6
|
DC Current per I/O Pin
|
40 mA
|
DC Current for 3.3V Pin
|
50 mA
|
Flash Memory
|
32 KB (ATmega328) of which 0.5 KB used by bootloader
|
SRAM
|
2 KB (ATmega328)
|
EEPROM
|
1 KB (ATmega328)
|
Clock Speed
|
16 MHz
|
The Arduino Uno can be powered via the USB connection or with an external power supply.
External (non-USB) power can come either from an AC-to-DC adapter (wall-wart) or battery. The adapter can be connected by plugging a 2.1mm center-positive plug into the board's power jack. Leads from a battery can be inserted in the Gnd and Vin pin headers of the POWER connector.
The board can operate on an external supply of 6 to 20 volts.
The Arduino Uno has a resettable polyfuse that protects your computer's USB ports from shorts and overcurrent. Although most computers provide their own internal protection, the fuse provides an extra layer of protection. If more than 500 mA is applied to the USB port, the fuse will automatically break the connection until the short or overload is removed.
Parts Necessary:
Arduino UNO or other Arduino board
USB programming cable
|
Arduino UNO and programming cable |
To start this tutorial make sure your Arduino is not sitting on a metal surface or accidental connection with wires or leads under the board.
1) Plug in the Arduino Uno via the input port. Notice the Green LED (Surface mount) on the board.
2) Notice, as you plug in another green, LED flashed a couple of times at Pin 13 for RX and TX standing for send and receive and this is like a handshake between the computer and the Arduino.
When you open the software you will find this window.
|
Image of Arduino IDE |
Next you need to select the Arduino UNO or other Arduino product you are using.
|
Image of how to select the Download Port for the Arduino UNO or other Arduino products. |
Next you must select the proper Serial port for communicating with the Arduino.
|
Selecting the dev/tty/usbmodemfd131 or other such port. |
Notice on other computers the number may be 141 and the tty. or cu. ports should work fine.
Now navigate to File and examples and select Blink from the Arduino example code.
|
Select BLINK |
Now we are ready to try out the Arduino BLINK program so when you select the program you will notice that it appears in the IDE.
|
Blink Program in Arduino code |
Now it is time to hit download and you will notice a bar at the bottom of the IDE with progress and when it says Compiling and then done the software is uploaded. Now notice how the little LED at pin 13 is flashing at a given rate of one time per second.
Now for fun look into the program above and change the flash rate of the LED to 500 near where it says delay in the program (marked in Red Below) and you will have changed the rate of the blink to 500 milliseconds.
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a second
}
If we attached an LED to pin 13 with a necessary resistor as detailed in the next chapter we would be able to change the rate of flashing of the LED with this software loop.
Now disconnect the Arduino UNO from the USB port and you will notice that the Arduino has gone off. What is great is the code is still there. If you have a 9-volt battery adapter first plug the battery into the adapter and then plug into the power port and your Arduino will begin the same behavior again flashing that surface mount LED at whatever rate you programmed it to flash.
Congratulations you have now confirmed the Arduino UNO is receiving and able to download code.
Now it is time to explore some other aspects of input and output to the Arduino.
Now time to download Firmata as we move to have the Arduino communicate with Maxuino and MAX MSP and Jitter.
|