/*
Name : Purushotham P
Date : 19-10-2023
Description : - Set up LEDs on pin GPIO18 and GPIO5 using the wowki simulator
- Turn pins GPIO18 and GPIO5 into PWM pins
- Gradually Increase brightness on these LEDs from zero to max voltage over 5 seconds (20% brightness after 1 second, 40% brightness after 2 seconds, and so on). Both pins should have equal brightness at all times
- Turn off LEDs for 2 seconds
- Increase to full brightness over 1 second (50% brightness after 0.5 second)
- Repeat steps 3-5 four times
- Permanently turn off
*/
const int led_pin1 = 18;// Define the pin number for the first LED (GPIO18)
const int led_pin2 = 5; // Define the pin number for the first LED (GPIO5)
int repeations = 1; // Initialize a counter for repetitions
void setup() {
// put your setup code here, to run once:
pinMode(led_pin1,OUTPUT); // Setting the first LED pin as OUTPUT
pinMode(led_pin2,OUTPUT); // Setting the second LED pin as OUTPUT
}
void loop() {
// put your main code here, to run repeatedly:
while(repeations < 5)// a loop runs for 4 times
{
for(int brightness=0; brightness<=255; brightness += 51)
{
analogWrite(led_pin1,brightness);//setting brightness for led1
analogWrite(led_pin2,brightness);//setting brighness for led2
delay(1000); //setting delay for one second
}
analogWrite(led_pin1,0); //set the brightness to 0 for led1
analogWrite(led_pin2,0);//set the brightness to 0 for led2
delay(2000);//delay 2 seconds
analogWrite(led_pin1,255);//set led1 to full brightness
analogWrite(led_pin2,255);//set led2 to full brightness
delay(1000);
analogWrite(led_pin1,127);//set led1 to half brightness
analogWrite(led_pin2,127);//set led1 to half brightness
delay(500); // dealy of 0.5 seconds
repeations++; // incriment of repeations
}
// at end finally both leds set to off permanently
analogWrite(led_pin1,0);
analogWrite(led_pin2,0);
}