Welcome the SimpleComponents Reference! The reference provides detailed documentation for each class and method in the SimpleComponents library. It is a useful resource for understanding how to use the various components and functions of the library.
int pin
: The digital pin number of the Arduino to which the LED is connected.bool isTurnedOn
: A flag to indicate whether the LED is turned on or off.SimpleLed(int pin)
Constructor for the SimpleLed
class. It initializes the pin
member with the given pin
argument.
Example Usage:
SimpleLed led(13); // Creates a SimpleLed object using pin 13.
void init()
Initializes the pin as an output pin.
Example Usage:
led.init(); // Initializes pin 13 as an output pin.
void on()
Turns the LED on by setting the pin to a high level. It also sets the isTurnedOn
flag to true
.
Example Usage:
led.on(); // Turns the LED on.
void off()
Turns the LED off by setting the pin to a low level. It also sets the isTurnedOn
flag to false
.
Example Usage:
led.off(); // Turns the LED off.
void toggle()
Toggles the state of the LED, turning it on if it is currently off and vice versa.
Example Usage:
led.toggle(); // Toggles the state of the LED.
void blink(int delayTimeInMs, int timesToBlink)
Makes the LED blink timesToBlink
times, with a delay of delayTimeInMs
milliseconds between each blink.
Example Usage:
led.blink(500, 5); // Makes the LED blink 5 times, with a 500ms delay between each blink.
void blink(int delayTimeInMs)
Makes the LED blink indefinitely, with a delay of delayTimeInMs
milliseconds between each blink.
Note: this function will only blink the LED once if it is called outside of a loop in the Arduino sketch.
Example Usage:
led.blink(500); // Makes the LED blink indefinitely, with a 500ms delay between each blink.
void blinkDot()
Makes the LED blink once, with a delay of 200 milliseconds between each blink.
The blink of this function corresponds to the dot in Morse code.
Example Usage:
led.blinkDot(); // Makes the LED blink once, with a 200ms delay between each blink.
void blinkDash()
Makes the LED blink three times, with a delay of 600 milliseconds between each blink.
The blink of this function corresponds to the dash in Morse code.
Example Usage:
led.blinkDash(); // Makes the LED blink three times, with a 600ms delay between each blink.
void blinkSOS()
Makes the LED blink the SOS pattern (three dots followed by three dashes followed by three dots).
Example Usage:
led.blinkSOS(); // Makes the LED blink the Morse code signal for "SOS".
bool getIsTurnedOn()
Returns the value of the isTurnedOn
flag.
Example Usage:
bool isOn = led.getIsTurnedOn(); // Stores the value of the isTurnedOn flag in the isOn variable.
byte pin
: The analog pin number of the Arduino to which the potentiometer is connected.int value
: The current value of the potentiometer.SimplePotentiometer(byte pin)
Constructor for the SimplePotentiometer
class. It initializes the pin
member with the given pin
argument.
Example Usage:
SimplePotentiometer pot(A0); // Creates a SimplePotentiometer object using pin A0.
void update()
Updates the value of the value
member by reading the potentiometerβs value from the pin
.
Note: This function is called inside
getValue()
so you do not need to call it yourself to update the potentiometer value when ever you want to get it.
Example Usage:
pot.update(); // Updates the value of the potentiometer.
int getValue()
Returns the current value of the value
member.
Example Usage:
int potValue = pot.getValue(); // Stores the current value of the potentiometer in the potValue variable. Remember update() is called inside this method.
void showValue()
Prints the current value of the value
member to the serial monitor.
Example Usage:
pot.showValue(); // Prints the current value of the potentiometer to the serial port.
We welcome contributions to the SimpleComponents library! If you have an idea for a new feature or a bug fix, please open an issue or a pull request. Weβre always looking for ways to make the library better, and we appreciate your help.