warning: Creating default object from empty value in /home/dr_rick/onearmedman.com/modules/taxonomy/taxonomy.pages.inc on line 33.


Tutorial 3: Fun With Pot and Vibrators

Buzzy BasicsBuzzy BasicsOkay, actually, that's a pot as in potentiometer. Nyuk, nyuk. Anyway, let have some fun here!

  • Connect pot to analog in pin

Buzzy Basics

Buzzy Basics

Analog Read/Write

  • Analog pins don't require pinMode -- they are fixed
  • analog read pins are on a separate set up pins
  • analogue write pins (PWM pins) are on 9, 10, and 11
  • analogWrite takes a pin and a value (but the value must be between 0 and 255)

Tutorial 2: Digital Read and Write

Knight LightsKnight LightsNow let's put some of this stuff together into a new circuit. You'll need four LEDs, four 220 ohm or 470 ohm resistors, one 1K ohm resistor, a push button, and a bunch of wires.

Hook four wires into the Arduino's digital outputs (check the code to see which ones.) Connect the smaller resistors to each of those wires, then connect an LED to each resistor with its short leg to ground. Be sure to hook up the 5V and GND lines between your Arduino and breadboard.

Knight Lights

Knight Lights

Other Cool Stuff

  • Math
    • max, min, contrain, randomSeed, random
  • Time
    • delay
      • important for adding pauses

Tutorial 1: Data and Serial

Arduino Hooked UpArduino Hooked UpNow we'll run the knight_rider_1 tutorial. Open up the files in the zip archive. All you need for this is to plug in the Arduino to your computer.

Once the board is plugged in, hit reset on the board, then click the Upload to I/O icon on the Arduino interface. Once that's done, click the Serial Monitor icon to see the numbers move up and down. Now you're talking (to the Arduino!)

Arduino Hooked Up

Arduino Hooked Up

Digital Read/Write

  • pinMode
    • takes the pin to be determined
    • takes the mode -> in or out
    • MUST do this for most pins. Forgetting this will get you in trouble

Control structures

  • if/else
    • simple branching
  • switch case
    • more complicate branching
    • for multiple cases

Copyright Mike Edwards 2006-2009. All content available under the Creative Commons Attribution ShareAlike license, unless otherwise noted.

Syndicate content