3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.


Arduino animatronics- make your awesome costumes more awesome!

Step 5Now let's have some fun!

Now let\
Example 1- LEDs
 
This is really simple- we're going to make two LEDs blink and another LED fade. The code will run over and over as soon as you apply power.

It's really easy to set up circuits like this using a breadboard. With each example I'll show how to wire everything up using either the servo board or an Arduino.

Copy and paste this sketch into your Arduino window-

/*
 * Example 1
 * LED Control
 * This example will blink two LEDs and then fade another LED
 * Honus 2010
 * Fading code created 1 Nov 2008 by David A. Mellis, modified 17 June 2009 by Tom Igoe
*/
  
 
   int ledPin1 = 13;  // control pin for LED 
   int ledPin2 = 12;
   int ledPin3 = 11;
  
 
 
   void setup() {
   pinMode(ledPin1, OUTPUT);  // sets the LED pin as output
   pinMode(ledPin2, OUTPUT);
   digitalWrite(ledPin1, LOW);  // sets the LED pin LOW (turns it off)
   digitalWrite(ledPin2, LOW);
  }
 
   void loop()
  {
 
   digitalWrite(ledPin1, HIGH);   // sets the LED pin HIGH (turns it on)
   delay(500);                    // waits 500 milliseconds
   digitalWrite(ledPin2, HIGH);
   delay(500);
   digitalWrite(ledPin1, LOW);    // sets the LED pin LOW (turns it off)
   delay(500);
   digitalWrite(ledPin2, LOW);
   delay(500);
 
  
   // fade in from min to max in increments of 5 points:
  for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
    // sets the value (range from 0 to 255):
    analogWrite(ledPin3, fadeValue);        
    // wait for 30 milliseconds to see the dimming effect   
    delay(40);                           
  }

  // fade out from max to min in increments of 5 points:
  for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
    // sets the value (range from 0 to 255):
    analogWrite(ledPin3, fadeValue);        
    // wait for 30 milliseconds to see the dimming effect   
    delay(40);                           
  }
  delay (2000); // wait two seconds 
  }
 
 



« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
619
Followers
23
Author:Honus(Multi-Bot)
I'm a former bicycle industry designer turned professional jeweler. I like working with my hands and am happiest when I'm in the shop building my creations. If you need help with your project just let...
more »