/*******************************************************************
write a c pl;us code for arduino to chase leds attached to pin 2 to 13 ,
then reverse the direction of chase
This code defines an array of integer values that
represent the pins where the LEDs are connected.
In the setup() function, it sets all of the pins as outputs.
In the loop() function, it turns off all of the LEDs and then turns on the current LED. It then moves to the next LED, and if it reaches the end of the chain, it reverses direction. Finally, it pauses for a short time
to create the chasing effect.
crterated by arvind patil code obtained from chat gpt
the aim of project is to show how chat gpt is useful
*******************************************************************/
// define the pins where the LEDs are connected
int ledPins[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
// set the initial direction of the chase
int direction = 1;
// set the initial LED to light up
int currentLED = 0;
void setup() {
// set all the LED pins as outputs
for (int i = 0; i < 12; i++) {
pinMode(ledPins[i], OUTPUT);
}
}
void loop() {
// turn off all LEDs
for (int i = 0; i < 12; i++) {
digitalWrite(ledPins[i], LOW);
}
// turn on the current LED
digitalWrite(ledPins[currentLED], HIGH);
// move to the next LED
currentLED += direction;
// if we reach the end of the chain, reverse direction
if (currentLED == 11 || currentLED == 0) {
direction *= -1;
}
// pause for a short time to create the "chasing" effect
delay(100);
}