Hello! New to the forum and to Arduino, I am developing a toy for a project for school. Its a kids game that has a trigger that starts a "multiplication of an array (Possible Food Options). Then, Displays the "Result" on a LCD. I am trying to control LED's with the Possible "Result". But I am stuck, can anyone lend me a hand?
#include <LiquidCrystal_I2C.h>
#define I2C_ADDR 0x27
#define LCD_COLUMNS 16
#define LCD_LINES 2
#define BUTTON_PIN 7 //Trigger
#define BUTTON_PIN1 8 //Trigger
LiquidCrystal_I2C lcd(I2C_ADDR, LCD_COLUMNS, LCD_LINES);
char *options[]={"Pie","Apple","Fish","Pizza"};
long option1;
void setup() {
pinMode(7, INPUT);
pinMode(8, INPUT);
pinMode(31, INPUT); //Ignore for now
pinMode(34, OUTPUT);//LED #1 (This is my backlight it will stay on, while no trigger has been set)
pinMode(37, OUTPUT);//LED #2
pinMode(38, OUTPUT);//LED #3
lcd.init();
lcd.backlight();
randomSeed(4);
Serial.begin(9600);
Serial.print(options[option1]);
}
void loop() {
int state=0;
state=digitalRead(BUTTON_PIN),(BUTTON_PIN1);
if(state==HIGH){
option1 = random(sizeof(options)/sizeof(char*));
lcd.clear();
delay(800);
lcd.print("PROCESSING....");
lcd.blink();
delay(4000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("You Win:");
lcd.setCursor(0,1);
lcd.print(options[option1]);
delay (4000);
lcd.clear();
}
else{
lcd.setCursor(0,0);
lcd.print("Ready...");
lcd.blink();
delay(1000);
}
if(digitalRead(options[option1])=="Pie")
{digitalWrite(37, HIGH);}
{digitalWrite(34, HIGH);
digitalWrite(37, LOW);
digitalWrite(38, LOW);}
if(digitalRead(options[option1])=="Apple")
{digitalWrite(37, HIGH);}
{digitalWrite(34, HIGH);
digitalWrite(37, LOW);
digitalWrite(38, LOW);}
if(digitalRead(options[option1])=="Fish")
{digitalWrite(38, HIGH);}
{digitalWrite(34, HIGH);
digitalWrite(37, LOW);
digitalWrite(38, LOW);}
if(digitalRead(options[option1])=="Pizza")
{digitalWrite(38, HIGH);}
{digitalWrite(34, HIGH);
digitalWrite(37, LOW);
digitalWrite(38, LOW);}
}