The revised code:
#include <LiquidCrystal (2).h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(53, 51, 41, 39, 33, 31);
//variables used:
int brightness = 175; //used for the brightness of the LEDs
int operation; //this will control which LED operation occurs
int previousNumber;//used to try and prevent any operation repeating twice in a row
int delayValue = 500; //this determines how long a function lasts before moving on
int i; //this will be used in for loops and array controlls
//pin declerations:
const int TFL = 3; //top front, left LED
const int TFR = 4; //top front, right LED
const int TRL = 5; //top rear, left LED
const int TRR = 6; //top rear, right LED
const int BFL = 7; //bottom front, left LED
const int BFR = 8; //bottom front, right LED
const int BRL = 9; //bottom rear, left LED
const int BRR = 10; //bottom rear, right LED
//function prototypes for LED operations:
void top();
void bottom();
void left();
void right();
void corners1();
void corners2();
void all();
//arrays used:
char chaseTop[4] = {TFL, TFR, TRR, TRL};
char chaseBottom[4] = {BFL, BFR, BRR, BRL};
char chaseLeftSide[4] = {TFL, BFL, BRL, TRL};
char chaseRightSide[4] = {TFR, BFR, BRR, TRR};
char chaseCorners[4] = {TFR, TRL, BRL, BFR};
char chaseCorners1[4] = {TFL, TRR, BRR, BFL};
void setup(){
lcd.begin(16,2);
//set up the LCD so we can see what it is doing
//the LED brighness pin is an analog INPUT by default.
//As we are using it as an analog input pin, we do not need to
//declare it's use.
//the LED brighness pin is an analog OUTPUT by default.
//As we are using it as an analog output pin, we do not need to
//declare it's use.
}
void loop(){
loops:
//TURN ALL PINS OFF
analogWrite(TFL, 0);
analogWrite(TFR, 0);
analogWrite(TRL, 0);
analogWrite(TRR, 0);
analogWrite(BFL, 0);
analogWrite(BFR, 0);
analogWrite(BRL, 0);
analogWrite(BRR, 0);
delay(50);
// brightnessRead = analogRead(brightPin); //read the potentiometer value on analog pin 0
// brightness = map(brightnessRead, 0, 1023, 0, 255); //map the brighness value from the analog reading
// range of 0 - 1023 to the brightness range of 0 - 255
randomSeed(analogRead(A7)); //pick a random place to start making random numbers from
operation = random(1, 13); //create a random number with a max of 13 and a min of 1.
//This will be used for choosing the LED operation.
if(operation == previousNumber){
goto loops;
}
else{
lcd.clear(); //eraxe the current contents of the LCD to display the new contents
switch(operation){
//perform a different function depending on the value of operation
case 1: //if 'operation' equals 1,
lcd.print("top()");
analogWrite(TFR, brightness); //turns on the top front right LED
analogWrite(TRR, brightness); //turns on the top back right LED
analogWrite(TFL, brightness); //turns on the top front left LED
analogWrite(TRL, brightness); //turns on the top back left LED
delay(delayValue);
break; //used to close switch statement
case 2: //if 'operation' equals 2,
lcd.print("bottom()");
analogWrite(BFR, brightness); //turns on the bottom front right LED
analogWrite(BRR, brightness); //turns on the bottom back right LED
analogWrite(BFL, brightness); //turns on the bottom front left LED
analogWrite(BRL, brightness); //turns on the bottom back left LED
delay(delayValue);
break; //used to close switch statement
case 3: //same as above
lcd.print("left()");
analogWrite(TFL, brightness); //turns on the top front left LED
analogWrite(TRL, brightness); //turns on the top back left LED
analogWrite(BFL, brightness); //turns on the top front left LED
analogWrite(BRL, brightness); //turns on the top back left LED
delay(delayValue);
break;
case 4:
lcd.print("right()");
analogWrite(TFR, brightness); //turns on the top front right LED
analogWrite(TRR, brightness); //turns on the top back right LED
analogWrite(BFR, brightness); //turns on the top front right LED
analogWrite(BRR, brightness); //turns on the top back right LED
delay(delayValue);
break;
case 5:
lcd.print("corners1()");
analogWrite(TFL, brightness); //turns on the top front left LED
analogWrite(BRR, brightness); //turns on the bottom back right LED
delay(delayValue);
break;
case 6:
lcd.print("corners2()");
analogWrite(TFR, brightness); //turns on the top front right LED
analogWrite(BRL, brightness); //turns on the bottom back left LED
delay(delayValue);
break;
case 7:
lcd.print("all()");
analogWrite(TFL, brightness);
analogWrite(TFR, brightness);
analogWrite(TRL, brightness);
analogWrite(TRR, brightness);
analogWrite(BFL, brightness);
analogWrite(BFR, brightness);
analogWrite(BRL, brightness);
analogWrite(BRR, brightness);
delay(delayValue);
break;
case 8:
lcd.print("chaseTop()");
for(int l = 0; l < 3; l++){
//a for loop has been used here to chase more than once
for(i = 0; i < 4; i++){
//this for loop turns on each LED in the array chaseTop
analogWrite(chaseTop[i], brightness);
delay(100);
analogWrite(chaseTop[i], 0);
}
i = 0; //return the value of i back to it's original value
}
break;
case 9:
lcd.print("chaseBottom()");
for(int l = 0; l < 3; l++){
//a for loop has been used here to chase more than once
for(i = 0; i < 4; i++){
//this for loop turns on each LED in the array chaseBottom
analogWrite(chaseBottom[i], brightness);
delay(100);
analogWrite(chaseBottom[i], 0);
}
i = 0; //return the value of i back to it's original value
}
break;
case 10:
lcd.print("chaseLeftSide()");
for(int l = 0; l < 3; l++){
//a for loop has been used here to chase more than once
for(i = 0; i < 4; i++){
//this for loop turns on each LED in the array chaseLeftSide
analogWrite(chaseLeftSide[i], brightness);
delay(100);
analogWrite(chaseLeftSide[i], 0);
}
i = 0; //return the value of i back to it's original value
}
break;
case 11:
lcd.print("chaseRightSide()");
for(int l = 0; l < 3; l++){
//a for loop has been used here to chase more than once
for(i = 0; i < 4; i++){
//this for loop turns on each LED in the array chaseRightSide
analogWrite(chaseRightSide[i], brightness);
delay(100);
analogWrite(chaseRightSide[i], 0);
}
i = 0; //return the value of i back to it's original value
}
break;
case 12:
lcd.print("chaseCorners()");
for(int l = 0; l < 3; l++){
//a for loop has been used here to chase more than once
for(i = 0; i < 4; i++){
//this for loop turns on each LED in the array chaseCorners
analogWrite(chaseCorners[i], brightness);
delay(100);
analogWrite(chaseCorners[i], 0);
}
i = 0; //return the value of i back to it's original value
}
break;
case 13:
lcd.print("chaseCorners1()");
for(int l = 0; l < 3; l++){
//a for loop has been used here to chase more than once
for(i = 0; i < 4; i++){
//this for loop turns on each LED in the array chaseCorners1
analogWrite(chaseCorners1[i], brightness);
delay(100);
analogWrite(chaseCorners1[i], 0);
}
i = 0; //return the value of i back to it's original value
}
break;
}
}
}