Light Game

Hi all,

I wanted some advice regarding a light game I am developping with an Arduino Uno. So far I have 4 red LEDs, a green LED and a white LED. The four red ones and the green one blink in sequence and I have a button attached to an interrupt which when triggered will make the white LED flash and count as a point scored if the green LED was lit at that moment. I also have a Piezo element to produce the sound of correct or incorrect input, a servo used as analog dial to indicate score and finally another button with another interrupt attached to it that will reset the points in the game, the speed and the servo analog dial. Each time 3 points are scored the speed of the game increases.

Now, my problems are the following. I tried to use a potentionmeter for the player to be able to chose the speed of the game by turning it higher or lower however the problem is to do this I need an attachInterrupt so that at any point of the game the potentiometer will increase the speed. The problem is I have seen that the potentionmeter requires to be connected to the analog pin and the attachInterrupts only map to digital Pins 2 and 3 in Arduino Uno. Any ideas how I could go about this?

My second problem is I have run out of ideas of how to improve my game further. I have considered creating a 2 player mode but I greatly struggled with it. It would be of great help if someone could hint me towards coming up with more ideas for the game.

Thank you in advance.

Now, my problems are the following. I tried to use a potentionmeter for the player to be able to chose the speed of the game by turning it higher or lower however the problem is to do this I need an attachInterrupt so that at any point of the game the potentiometer will increase the speed.

Why? Changing an analog device will not trigger an interrupt.

None of your uses of interrupts is correct. The only reason that you would need to use interrupts to read switches is if you are foolishly using delay(). If you are, stop it. Read, understand, and embrace the blink with delay example's philosophy, and read the switches and potentiometer on every pass through loop().

Thank you for your reply PaulS.

I understand what you mean reading switch values each pass through the loop. However I do not understand why you said my use of the interrupts was incorrect. Instead of checking for each pass through the loop if the button was pressed and if it was the right LED I find it simpler to interrupt. If the input is incorrect the piezo gives the sound for wrong answer else it gives for the right answer.

Also as I mentioned before each time a player scores three points the speed increases. The problem with reading the potentiometer through each pass is that if the speed has increased due to points scored the potentiometer will adjust it to its own analog output. In other words I wanted to have as an option to change speed if the potentiometer were manipulated however the loop will make the speed remain at the potentiometer reading and will never increase when points are scored.

I apologise in advance if im not understanding something correctly. I am new to Arduino so please bare with me.