#include <wiringPi.h>
#include <softPwm.h>
#include <stdio.h>
#include <unistd.h>
#define LED_PIN_18 1 // GPIO18 corresponds to pin 1 on WiringPi
#define LED_PIN_5 24 // GPIO5 corresponds to pin 24 on WiringPi
int main() {
if (wiringPiSetup() == -1) {
return 1;
}
// Set the GPIO pins
pinMode(LED_PIN_18, OUTPUT);
pinMode(LED_PIN_5, OUTPUT);
// Gradually increase brightness over 5 seconds
softPwmCreate(LED_PIN_18, 0, 100); // Initialize PWM on GPIO18
softPwmCreate(LED_PIN_5, 0, 100); // Initialize PWM on GPIO5
for (int duty_cycle = 0; duty_cycle <= 100; duty_cycle += 20) {
softPwmWrite(LED_PIN_18, duty_cycle);
softPwmWrite(LED_PIN_5, duty_cycle);
sleep(1);
}
// Turn off LEDs for 2 seconds
softPwmWrite(LED_PIN_18, 0);
softPwmWrite(LED_PIN_5, 0);
sleep(2);
// Increase to full brightness over 1 second
for (int duty_cycle = 0; duty_cycle <= 50; duty_cycle += 10) {
softPwmWrite(LED_PIN_18, duty_cycle);
softPwmWrite(LED_PIN_5, duty_cycle);
usleep(500000); // Sleep for 0.5 seconds
}
// Repeat steps 3-5 four times
for (int repeat = 0; repeat < 4; repeat++) {
softPwmWrite(LED_PIN_18, 0);
softPwmWrite(LED_PIN_5, 0);
sleep(2);
for (int duty_cycle = 0; duty_cycle <= 50; duty_cycle += 10) {
softPwmWrite(LED_PIN_18, duty_cycle);
softPwmWrite(LED_PIN_5, duty_cycle);
usleep(500000); // Sleep for 0.5 seconds
}
}
// Permanently turn off
softPwmWrite(LED_PIN_18, 0);
softPwmWrite(LED_PIN_5, 0);
return 0;
}