Freeduino Programming Instructions

From NYC Resistor Wiki
Jump to: navigation, search

These are scratch notes in preparation for Feb 23 Freeduino 101 class

Grab the 0022 release of the Arduino IDE (Interactive Development Environment <- take that you acronym happy programmers)

Mac OS:[edit]

  1. Download the arduino-0022.dmg file from the Arduino website at [1]
  2. Also install the FTDI driver. You may need to grab the latest and greatest FTDI drivers from [2]
  3. Reboot so the driver registers.

The Arduino programming interface for version 022 defaults to the Uno board so select duemilanove from the board selector menu.

Linux:[edit]

  1. You'll need to do a bit of pre-work to get the Arduino IDE working in your specific flavor of linux. If you're running linux then you should be more than capable of handling this yourself. Here's some guidelines on the Arduino playground site: [3]
  2. Download the arduino-0022.tgz file from the Arduino website at [4]

Windows PC:[edit]

  1. Download the arduino-0022.zip file from the Arduino website at [5]
  2. Unzip the file, preserving the folder structure.
  3. Plugin your board and wait for it to fail. Failure is good.
  4. Install the drivers for Duemilanove (not Uno), per the specific steps over on the Arduino website: [6]. You may need to grab the latest and greatest FTDI drivers from [7]

For extra help on any of the platforms check the Arduino pages proper: http://arduino.cc/en/Guide/HomePage

Run the blink program[edit]

The LED blink example will be in File > Examples > 1.Basics > Blink. Open it! Confirm you are targeting the right board: Tools > Board > Duemilanove with ATmega 168 Select the correct serial port for your environment Upload the program! The led on the board (at pin 13) should start to blink.

Make the LED blink to your will[edit]

Change the program to make the led blink faster or slower. Save the program. Upload the program! Laugh with an evil maniacal laugh!

Try out a digital input[edit]

Get to know and love your breadboard.
Put your push button on the breadboard.
Connect switch input (white on reference board) to pin 2
Connect ground (blue on reference board) to ground (pin 4 from last)
Connect ground to input using a pull-down resistor of about 10-22k (red-red-orange)
Connect switch power (red on reference board) to 3.3v power (pin 2 from last)

Compile and upload DigitalReadSerial.
Open the serial monitor (little alien tv icon)

You should see a beautiful stream on zeros
Push and hold the button: see a beautiful stream of ones!

Doesn't work? Turn that switch around.

Success!

Now, modify the program to use the digital in to turn your onboard led on and off.

Try out an analog input[edit]

Solder up wires to pot: Black to left, red to right, green to middle. Doesn't actually matter which is left and which is right.
Red/right to 3.3v (pin 2 from last).
Black/ground to ground (pin 4 from last).
Green/wiper to Analog In Zero (A0)
No pull down resistor required.

Compile and upload AnalogReadSerial.
Open the serial monitor (little alien tv icon)

You should see a beautiful stream on zeros
Turn the little stick, See the numbers fly!

Doesn't work? Check your solder joints.

Success!

Try out an analog output[edit]

Clean out your breadboard, or turn it around and use the other side. Connect long leg of offboard LED (white on reference board) to digital output pin 9
Connect short leg of offboard LED a current limiting resistor of about 10-22k (red-red-orange) Connect resistor (red on reference board) to 3.3v power (pin 2 from last)

Compile and upload Fade.
Watch the pretty light breathe.

Doesn't work? Flip the LED legs.

See something else: Swap for a very very very low resistor e.g. 10Ohms (brown-black-brown), See how bright it is!

Why does it work: Averaging!

Not the LED, your eyes! POV. Prove it with Raf's oscilloscope.

Success!