Lab 1 : Blink

Submitted by fchasen on Sat, 02/02/2013 - 18:02

Description

When trying out the blue LED, I was impressed by the intensity of light. I wanted to be able to turn it down and so rather than just make the light blink, as per the sample code, my code slowly pulses the light using the analogWrite command.

 

Components Used

  •  LED (Blue)
  • Arduino Uno
  • Breadboard
  • 220-ohm Resistor

Code

 

/*
  Fred Chasen
  Pulse Light
 */
 
// Connect to Pin 11, for analog
int led = 11;
int minamount = 5;
int x = minamount;
int sign = 1;
 
void setup() {                
  //Serial.begin(9600);
}
 
void loop() {
  
  analogWrite(led, x);   
  delay(10);               
    x = x + sign;
    
    if(x > 255 || x < minamount){
     sign = sign * -1;
    }
    
    //Serial.println(x); 
}
 
 

 

 

photo-4_1.JPG
0
Your rating: None
Drupal theme by Kiwi Themes.