• 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!


digital output

Page history last edited by Kristin Lucas 15 years, 5 months ago
Scroll down or click on links for programs and schematics:
LEDS  (scroll down)

• Blink two LEDs simultaneously - Test your skills: Now try to figure out how to blink two LEDs alternately.

• Blink an LED without Delay
DC MOTORS - super crazy fast motors
STEPPER MOTORS - reliable, accurate, good for timing and gears
• Add Random time to your Unipolar Stepper Motor sketch
Change the rotation direction of your Unipolar Stepper Motor
SERVO MOTORS - zip with speed from one degree of rotation to another

Blink two LEDs simultaneously
2 LEDs
1 390 ohm resistor (give or take 20% resistor value)
1 Arduino Diecimila
jumper wire


Connect a jumper from digital GROUND to your breadboard. 

Connect the long lead of an LED from port 13 on your breadboard to positive, and connect the short lead of your LED to ground on your breadboard.
Now connect a second LED to port 12.
Remember: port 13 has a built in resistor, pin 12 does not.
You will need to add a 390 ohm resistor to your breadboard between the LED wired to port 12 and positive. 



 * Blink


 * The basic Arduino example.  Turns on an LED on for one second,

 * then off for one second, and so on...  We use pin 13 because,

 * depending on your Arduino board, it has either a built-in LED

 * or a built-in resistor so that you need only an LED.


 * http://www.arduino.cc/en/Tutorial/Blink


int ledPinB = 12;                // LED connected to digital pin 12

int ledPin = 13;                // LED connected to digital pin 13

void setup()                    // run once, when the sketch starts


  pinMode(ledPin, OUTPUT);      // sets the digital pin as output

  pinMode(ledPinB, OUTPUT);      // sets the digital pin as output


void loop()                     // run over and over again


  digitalWrite(ledPin, HIGH);   // sets the LED on

  digitalWrite(ledPinB, HIGH);   // sets the LED on

  delay(1000);                  // waits for a second

  digitalWrite(ledPin, LOW);    // sets the LED off

  digitalWrite(ledPinB, LOW);    // sets the LED off

  delay(1000);                  // waits for a second


Blink an LED without delay


Delay causes everything in the program to pause. If you have a program in which several operations are being performed you should avoid using delay, unless you want this effect. This program also makes use of the serial port feature of the Arduino programming environment. Once the program is running, try clicking on the SERIAL MONITOR icon (next to the UPLOAD button). If the program is running correctly, you will see the word "blink" printed at the bottom of your sketch each time the LED blinks.


1 Arduino Diecimila


int ledPin = 13; // choose the pin for the LED

int inPot = 2;   // choose the input pin (for a pushbutton)

int potval = 0;     // variable for reading the pin status

unsigned long ledCounter = 0; // a special int variable for really big numbers

int toggle = 0; // this will be either 1 or 0 and contolls the light turning on or off

void setup() {

  pinMode(ledPin, OUTPUT);  // declare LED as output



void loop(){


   inPot = analogRead(inPot);  // read input value



  ledCounter ++; // adds 1 to our variable

  if (ledCounter == 300000) { // if it equals 300000

    ledCounter = 0; // reset counter

    Serial.println("blink"); //prints the word bilnk in the Serial monitor

    if (toggle == 0){ // check out light switch variable

      digitalWrite(ledPin, HIGH); // turns light on

      toggle = 1; // changes the switch for next time through


    else if (toggle == 1){ // if toggle is 1 and not 0 then ...

      digitalWrite(ledPin, LOW); // turns light on

      toggle = 0; // changes the switch for next time through




Comments (0)

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