//Program to pulse 2 white LEDs for J. Pasachoff. Written by Jason Mativi, Williams College. //LED1: pulse with a period of 5.4s. //LED2: pulse with a period of 10s, about 3 times brighter than LED1. int counterOne = 1; long counterTwo = 1L; int incrementOne = 1; int incrementTwo = 1; int LEDOneLimit = 85; int LEDTwoLimit = 250; int LEDOneOutput = 0; int LEDTwoOutput = 0; int cOneLimit = 27000; //Very near 5.4s long cTwoLimit = 50000L; //Very near 10s void setup() { pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT); digitalWrite(3, LOW); //GND for LED digitalWrite(7, LOW); //GND for LED //Only needed if debugging code below is active //Serial.begin(9600); } void loop() { if(counterOne >= cOneLimit || counterOne <= 0) { incrementOne = incrementOne * -1; } if(counterTwo >= cTwoLimit || counterTwo <= 0) { incrementTwo = incrementTwo * -1; } counterOne = counterOne + incrementOne; counterTwo = counterTwo + incrementTwo; LEDOneOutput = map(counterOne, 0, cOneLimit, 0, LEDOneLimit); LEDTwoOutput = map(counterTwo, 0, cTwoLimit, 0, LEDTwoLimit); analogWrite(6, LEDOneOutput); analogWrite(5, LEDTwoOutput); //For debugging and figuring out time /*Serial.print(millis()); Serial.print(" "); Serial.print(counterOne); Serial.print(" "); Serial.println(counterTwo);*/ }