The CAR_LED library simplifies working with LED outputs on Arduino. It provides functionality for setting high/low states, toggling, and blinking with customizable timings.
To use the CAR_LED library, include it in your project by copying the CAR_LED.h and CAR_LED.cpp files into your project's directory and include the header file in your sketch.
#include "CAR_LED.h"The CAR_LED_BlinkState enum defines the possible states for output blinking:
DISABLE: Blinking is disabled.DELAY: Delay before starting the blink.BLINK: Blinking is active.
CAR_LED(byte p_outputPin);p_outputPin: The pin number to which the LED is attached.
Sets the output to high.
Sets the output to low.
Toggles the output state.
Starts blinking with the specified low and high times.
p_lowTime: Time in milliseconds the output stays low.p_highTime: Time in milliseconds the output stays high.
Starts blinking with the specified low, high, and delay times.
p_lowTime: Time in milliseconds the output stays low.p_highTime: Time in milliseconds the output stays high.p_delayTime: Delay time in milliseconds before starting the blink.
void blink(unsigned int p_lowTime, unsigned int p_highTime, unsigned int p_delayTime, int p_blinkTimes)
Starts blinking with the specified low, high, delay times, and number of blink cycles.
p_lowTime: Time in milliseconds the output stays low.p_highTime: Time in milliseconds the output stays high.p_delayTime: Delay time in milliseconds before starting the blink.p_blinkTimes: Number of blink cycles. If set to -1, blinking continues indefinitely.
Returns the current output state.
Handles the output state and manages blinking. This method should be called repeatedly in the loop() function of your sketch.
#include <CAR_LED.h>
CAR_LED output(13);
void setup() {
Serial.begin(9600);
}
void loop() {
output.high();
delay(1000);
output.low();
delay(1000);
}#include <CAR_LED.h>
CAR_LED output(13);
void setup() {
Serial.begin(9600);
}
void loop() {
output.toggle();
delay(500);
}#include <CAR_LED.h>
CAR_LED output(13);
void setup() {
Serial.begin(9600);
output.blink(500, 500);
}
void loop() {
output.loop();
}#include <CAR_LED.h>
CAR_LED output(13);
void setup() {
Serial.begin(9600);
output.blink(500, 500, 2000);
}
void loop() {
output.loop();
}#include <CAR_LED.h>
CAR_LED output(13);
void setup() {
Serial.begin(9600);
output.blink(500, 500, 0, 10);
}
void loop() {
output.loop();
}