MyLedIO is a simple Arduino library for controlling multiple LEDs connected to a digital output pin.
It allows easy initialization and state management for turning the LED on or off.
- Easy setup with
init() - Simple methods to turn the LED on/off
- Retrieve current LED state with
getState()
- Download the repository as a ZIP file or clone it to your Arduino libraries folder
git clone git clone https://github.com/hanzeelvilla/MyLedIO.git- Place the MyLedIO folder into your Arduino libraries directory (typically Documents/Arduino/libraries on most systems).
- Restart the Arduino IDE if it was open during installation.
To begin using the MyLedIO library, follow these steps:
-
Connect your LED
- Connect the longer leg (anode) of the LED to a digital pin on your Arduino (e.g., pin 15).
- Connect the shorter leg (cathode) to a resistor (220Ω recommended), then to GND.
Warning
Ensure the led is connected properly to avoid short circuits or damage to the board.
-
Include the library in your sketch
Add this at the top of your.inofile:#include "MyLedIO.h"
-
Create an instance
Define your LED object by passing the pin number:
MyLedIO redLed(15);
-
Initialize in
setup()void setup() { redLed.init(); }
-
Control the LED in
loop()void loop() { redLed.turnOn(); delay(1000); redLed.turnOff(); delay(1000); }
| Method | Description | Returns |
|---|---|---|
init() |
Initializes the LED pin as an output and turns it off. | void |
turnOn() |
Turns the LED on. | void |
turnOff() |
Turns the LED off. | void |
getState() |
Returns the current state of the LED. | bool (true if ON, false if OFF) |