/* Origanal code:
* Author (for Arduino): Helen Miles ([email protected])
* Adapted for ESP32 : Graeme Tyson ([email protected])
* Functions to set up and use lights with the ESP32
* Change made by me to call and use header file as part of worksheet 3
* New copy taken for worksheet 4 exercise 2 - Randomisation
* coding ideas from
* https://www.bing.com/search?pglt=41&q=generate+random+selection+from+an+array+in+arduino&cvid=a65cc7f2cd374761bb6d892836aa0cec&gs_lcrp=EgZjaHJvbWUyBggAEEUYOdIBCTEzNTgzajBqMagCALACAA&FORM=ANNTA1&PC=EDGEDB&ntref=1
* https://www.bing.com/search?q=how+to+loop+a+random+led+light+selection+arduino&qs=n&form=QBRE&sp=-1&ghc=2&lq=0&pq=how+to+loop+a+random+led+light+selection+arduino&sc=10-48&sk=&cvid=570BF986800244A4A399D8BC05FC2936&ghsh=0&ghacc=0&ghpl=
*/
#include "led_header.h"//tells it to use the information from the header file
//int myLED_Array [5] = {LED_ORANGE, LED_GREEN, LED_RED, LED_YELLOW, LED_BLUE};//these are the LEDs that are set up wihtin the header code
//int myLED_Array [5] = {18, 21, 5, 19, 22};
//int randomArray = random(0,4);
//int random_LED = myLED_Array[randomArray];
//int ledPins[] = {18, 21, 5, 19, 22}; //moved to header file
//int numLeds = 5; // moved to header file
//int randLed = 0; // moved to header file
void setup() {
//setupLightPins();
//setupButton();
Serial.begin(115200);
for (int i = 0; i < numLeds; i++) {
pinMode(ledPins[i], OUTPUT); // Set the LED pins as outputs
}
}
void loop() {
randLed = random(0, numLeds); // Generate a random number between 0 and numLeds
digitalWrite(ledPins[randLed], HIGH); // Turn on the selected LED
delay(1000); // Wait for 1 second
digitalWrite(ledPins[randLed], LOW); // Turn off the selected LED
delay(1000); // Wait for 1 second
}
/*for (int randomArray = random(0,4);
int random_LED = myLED_Array[randomArray];) {
digitalWrite (random_LED, HIGH);// turn all the lights on in order of array
Serial.println (random_LED);//print array as pass through it
delay (1500); //slows it down so you can see the lights come on and off
digitalWrite (random_LED, LOW);//turn all the lights off again
*/
//checkButton();
//if(buttonPressed){
//digitalWrite (random_LED, HIGH);// turn all the lights on in order of array
//Serial.println (random_LED);//print array as pass through it
//delay (1500); //slows it down so you can see the lights come on and off
//digitalWrite (random_LED, LOW);//turn all the lights off again
//void loop(){
//checkButton();
//if(buttonPressed){
//digitalWrite (random_LED, HIGH);// turn all the lights on in order of array
//Serial.println (random_LED);//print array as pass through it
//delay (1500); //slows it down so you can see the lights come on and off
//digitalWrite (random_LED, LOW);//turn all the lights off again
//delay (10);