The aim of this project was to make a random number picker, with 10 lights, and each light representing a number from 1 to 10. It would change the light being lit along the line- lighting each light one by one- and when it lands on the randomly generated number- it would stop. however- the lighting no longer initiates, while I was able to see that beforehand, nothing is happening now. I've also attached a picture of the project to show what I'm trying to do.
Any help would be greatly appreciated.
//includes entropy
#include <Entropy.h>
//chooses random number
uint8_t random_byte;
// A variable to set a delay time between each LED
int delayTime = 40;
// A variable to store which LED we are currently working on
int currentLED = 4;
// A variable to store the direction of travel of LEDs
int dir = 1;
// A variable to store the last time we changed something
unsigned long timeChanged = 0;
// Create an array to hold the value for each LED pin
byte ledPin[] = {4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
void setup() {
choosing();
// Set all pins for OUTPUT
for (int x=0; x<10; x++) {
pinMode(ledPin[x], OUTPUT);
}
// Set up the
timeChanged = millis();
}
void loop() {
// Check whether it has been long enough
if ((millis() - timeChanged) > delayTime) {
// Turn off all of the LEDs
for (int x=0; x<10; x++) {
digitalWrite(ledPin[x], LOW);
}
// Turn on the current LED
digitalWrite(ledPin[currentLED], HIGH);
// Increment by the direction value
currentLED += dir;
// If we are at the end of a row, change direction
if (currentLED == 9) {
dir = -1;
}
if (currentLED == 0) {
dir = 1;
}
// Store the current time as the time we last changed LEDs
timeChanged = millis();
}
}
void choosing() {
delay(2000);
random_byte = Entropy.random(1,11); // returns a value from 1 to 10
}