// https://wokwi.com/projects/346778138320044627
// Fri 28 Oct 16:03:11 UTC 2022
// Blink an LED, over and over ('endless loop')
void LED_ON() {
digitalWrite(LED_BUILTIN, 1);
}
void LED_OFF() {
digitalWrite(LED_BUILTIN, 0);
}
// ON_TIME 200 OFF_TIME 1000
// WEIGHT 5 UNIT_TIME 4
// SCALE 50
#define WEIGHT 5 // OFF to ON ratio (time intervals)
// larger WEIGHT gives more OFF time
#define UNIT_TIME 4 // basis of all other timings
#define SCALE 50 // scales all times evenly
#define ON_TIME (UNIT_TIME * SCALE)
#define OFF_TIME (ON_TIME * WEIGHT)
void report() {
Serial.println("\n The red LED is marked 'L' on the Uno.");
Serial.println(" This program makes it blink.");
Serial.print("\n Your ON_TIME: ");
Serial.print(ON_TIME);
Serial.print(" Your OFF_TIME: ");
Serial.println(OFF_TIME);
Serial.println("");
}
void LED_BLINK () {
LED_ON();
delay(ON_TIME);
LED_OFF();
delay(OFF_TIME);
}
void setup_GPIO() {
pinMode(LED_BUILTIN, OUTPUT);
LED_OFF();
}
void setup_serial() {
Serial.begin(9600);
}
void setup() {
setup_GPIO();
setup_serial();
report();
}
void loop() {
LED_BLINK();
}
// END.