Theory
The connection of components for the custom LED display code would depend on the specific components you are using. However, here is a general example of how to connect the components:
- Connect the anode (positive) of each LED to the corresponding pin specified in the pinArray variable in the code.
- Connect the cathode (negative) of each LED to a common ground pin on the Arduino board.
- Connect the ground pin on the Arduino board to the common ground of the power source you are using.
- Connect the 5V pin on the Arduino board to the positive terminal of the power source you are using.
It’s important to note that different LEDs may have different voltage and current requirements, so you may need to use a current-limiting resistor in series with each LED to prevent damage. The value of the resistor depends on the specifications of the LED, so consult the datasheet for your specific LED.
It’s also important to note that the code and connection details provided here are just an example, and you may need to make changes to suit your specific needs and hardware setup.
Coding
/*
Function: Custom LED Display
Prepared By: Krishnarajsinh Jadav
Website: http://www.Kraj.in
*/
const int numOfLEDs = 24; // Number of LEDs in the display
const int pinArray[numOfLEDs] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25}; // Define the pins for the LEDs
void setup() {
for (int i = 0; i < numOfLEDs; i++) {
pinMode(pinArray[i], OUTPUT); // Set each pin as an output
}
}
void loop() {
for (int i = 0; i < numOfLEDs; i++) {
digitalWrite(pinArray[i], HIGH); // Turn on the current LED
delay(100); // Delay to create a visual pattern
digitalWrite(pinArray[i], LOW); // Turn off the current LED
}
for (int i = numOfLEDs – 1; i >= 0; i–) {
digitalWrite(pinArray[i], HIGH); // Turn on the current LED
delay(100); // Delay to create a visual pattern
digitalWrite(pinArray[i], LOW); // Turn off the current LED
}
}
0 Comments