Go Down

Topic: Simon Says project (Read 457 times) previous topic - next topic

Lilrex

ok so my buttons are working... for some reason the leds are staying on and turning off when i press the button down but either way it is working.


but when i call the userIn() function the code just ignores my checks and turns on the lights, prints the serial line and then progresses down. 

Code: [Select]
   for (int i = 0;  i < 4;)

  while(buttonState !=4)
  {
  {
    if(buttonState != 4 && BB == LOW)



I am trying to "pause" the program and await the users button selection, and then add those button selections to an array so i can compare them afterwards.

I know arduino cannot be paused thats why it is in " "  but i need something similar.

cattledog

Quote
but when i call the userIn() function the code just ignores my checks and turns on the lights, prints the serial line and then progresses down. 
When you enter the function, add serial print outs of the variables used in the conditional tests.

Code: [Select]
if(buttonState != 4 && BB == LOW)

What is the value of BB? If the switch is wired correctly, and the input pin is set to INPUT_PULLUP mode, the value of BB can not be low if it is not pressed.

I think you have some extra brackets in userIn(), but I don't think that is what is causing your issue.

Quote
ok so my buttons are working... for some reason the leds are staying on and turning off when i press the button down but either way it is working.
Why are the led's wired so that one leg is common with a button pin leg? I would suggest moving the leds to a different place on the breadboard where they are independent of the buttons..

wolframore

So much easier when we can see the wiring... he's right you need the get the LED's away from the same row as the buttons.
Bad Boys Rate Our Young Girls But Violet Goes willingly - Get Some Now :) - ELI the ICE man

Go Up