• If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!



Page history last edited by PBworks 16 years, 5 months ago


Ok, so here it is. As I get the time I will post code, schematics, and any other information that we cover in class. This is a wiki which means that everyone in class can participate. So feel free to post your own notes or code or start a new page on something that should be covered in more detail.


NOTE: Try to keep the site as neat and user friendly as possible. When posting code use courier new for the font, everything else should stay as default. I will expand the below examples with a description and schematics in the next few days. If anyone is motivated enough to post their own example please do the same and stick to the overall format. Enjoy! -Brian


Two LED Example

One LED blinks quickly while the other blinks slowly using a 'for' loop.


Switch and Flashing Output

Using 'if' and 'for' statements to blink a light when a switch is pressed. Was shown in class hooked up to a MOSFET.


Dimming LEDs

Not covered in class, yet. Introduces PWM to dim and brighten an LED (think Mac 'heartbeat') on one of the digital pins marked PWM (11,10,9,6,5,3).


Flicker Sketch

Not covered in class either. Uses an array and analogWrite to create a flicker effect on an LED connected to a PWM pin.



I'm concerned that there isn't enough time in class to cover analog-ness as thoroughly as I'd like. So for this project I want to concentrate on the issue at hand: moving servos. There are currently 2 challenges that have to be overcome: 1) there are no official servo commands so we have to make our own and 2) a servo has to be updated, or a signal has to be sent to it, every 20ms or else the servo will loose its position. The first problem can be addressed with a new function named servoPulse which can be called from within our program telling it a servo pin number and an angle and it will send the necessary pulses to move the servo into position. The second problem has to be solved in the program to make sure that the servoPulse function is called every 20ms no matter what is happening in the program. So a delay of 1 second has to be a looping call to servoPulse for 50 cycles. Anyway, following are a 3 examples for 3 different types of servo movement: direct control from one angle to the next, slowly stepping from one angle to another, and scaling a sensor reading to the servo position. Try all three to gain a better understanding of how to work with servos.


10º, 90º, 170º

Moves the servo to three different positions, waiting for 1 second in between each.


Back and Forth

Uses a for loop to slowly oscillate the servo from 10º to 170º and back again.


Sensor to Servo Scaling

Takes an analog input from a potentiometer or other variable resistor and scales the reading to a servo position.



Serial Sensor Test

Sometimes its neccessary to test a variable resistor to see what kind of values you get from it. Using serial communication and the 'serial monitor', this program reads an analog input and displays the value.



How to wire up an Arduino on a Radio Shack perf board or some other ingenious and sinister method of connecting wires.


Real Barebones Arduino

After reading how to wire up your own Arduino maybe you should look at this...



Links and info for various types of motor.





Comments (0)

You don't have permission to comment on this page.