PWM BASED LIGHT WAVES USING MSP430G2553 FOR CHRISTMAS CRIB

Photo of author

By Jackson Taylor

YouTube video
PROGRAM

int led = 10;           // the pin that the LED is attached to
int brightness = 0;    // how bright the LED is
int fadeAmount = 5;    // how many points to fade the LED by
int brightness2 = 0;
// the setup routine runs once when you press reset:
void setup() {
   // declare pin 9 to be an output:
   pinMode(led, OUTPUT);  pinMode(11, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
   // set the brightness of pin 9:
   analogWrite(P1_2, brightness);
     brightness2=  255-brightness;
 analogWrite(P2_1, brightness2);
   brightness = brightness + fadeAmount;
   brightness2=  255-brightness;
   // reverse the direction of the fading at the ends of the fade:
   if (brightness == 0 || brightness == 255) {
     fadeAmount = -fadeAmount ;
   }
   // wait for 30 milliseconds to see the dimming effect
   delay(6);
 }
See also
TEMPERATURE SENSOR - LM35 -MSP430G2553 - ENERGIA