Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

i have a project to builu a slot machine. If the user gets the lucky number, the

ID: 3839130 • Letter: I

Question

i have a project to builu a slot machine. If the user gets the lucky number, the liquid display will say Jackpot! You Win!" on its screen and a noise will play only on Jackpots. We might add lights to it that repeatedly go off as well. This will utilize the components given in the Arduino kit only and be inspired by the Crystal ball project, and its coding is writter with this submittion. The case statements will work perfectly for this since they work for multiple outcomes. The LED lights will be in a while loop so that they in a loop during the statement. The usage of the coding, break will end the loop as well. Connecting the micro controller with this idea will be simple but the coding is the part that I need help with. I want to add other things that can happen even if the user doesn't hit a Jackpot such as a red LED light being on that means "Try again. Insert coins." The coding I have is covering everything, but not the sensor, so I just need to modify the coding to fit the sensor please. The sensor is called "force sensitive resistor. ll include the library code #include

Explanation / Answer

//Create a crystal ball to tell you the future! #include LiquidCrystal lcd(12, 11, 5, 4, 3, 2); const int switchPin = 6; int switchState = 0; int prevSwitchState = 0; int reply; void setup(){ lcd.begin(16, 2); pinMode(switchPin, INPUT); lcd.print("Ask the"); lcd.setCursor(0,1); lcd.print("Crystal Ball!"); } void loop(){ switchState = digitalRead(switchPin); if(switchState!= prevSwitchState){ if(switchState == LOW){ reply = random(8); lcd.clear(); lcd.setCursor(0, 0); lcd.print("The ball says: "); lcd.setCursor(0, 1); switch(reply){ case 0: lcd.print("YES"); break; case 1: lcd.print("Most likely"); break; case 2: lcd.print("Certainly"); break; case 3: lcd.print("Outlook good"); break; case 4: lcd.print("Unsure"); break; case 5: lcd.print("Ask again"); break; case 6: lcd.print("Doubtful"); break; case 7: lcd.print("NO"); break; } } } prevSwitchState = switchState; }