Throbbing+LED's

=Throbbing LED=

Linear:
/* Linear Throbing LED This program uses a simple count to vary the LED intensity. The LED is connected to pin 11, which is configured as an OUTPUT. */

int LED = 11; //LED on pin 11// //int i = 0;// intensity counting variable

void setup { pinMode(LED, OUTPUT); //tell Arduino LED is an output// //}//

//void loop{//

//for (i = 0; i < 255; i++) {// loop from 0 to 254 (fade in) analogWrite(LED, i); //set the LED brightness// //delay(10);// Wait 10ms }

for (i = 255; i > 0; i--) { //loop from 255 to 1 (fade out)//

//analogWrite(LED, i);// set the LED brightness delay(10); // Wait 10ms } }

Non - Linear:
/* Non Linear Throbbing LED From Earthshine Project 7 This program uses a sin function to vary the LED intensity. The LED is connected to pin 11, which is configured as an OUTPUT. The argument of the sin goes from 0 to PI which is then multiplied by 255 to set the PWM output */

int ledPin = 11; float sinVal; int ledVal = 0;

void setup { pinMode(ledPin, OUTPUT); }

void loop { for (int x=0; x<180; x++) { //convert degrees to radians// then obtain sin value sinVal = (sin(x*(3.1412/180))); ledVal = int(sinVal*255); analogWrite(ledPin, ledVal); delay(200); } }