Hi @All,
im using the GrovePi+ StarterKit on Raspberry Pi 3.
I have a serious problem with the “Button v1.2”. The buttonState switches
sometimes to 1 but the button was not pressed! When i increase the delay
to read the state, the problem happens less times in a while loop, but the
examples use 100mil secs.
I tried python and c++ sources, but its the same problem in both languages.
Is it a hardware or a code problem?
thanks in advance
Code c++:
void checkButton(int button_state, int button_pin)
{
button_state = digitalRead(button_pin); // read the button state
printf("[pin %d][button state = ", button_pin); // and print it on screen
if(button_state == 0)
printf("not pressed]\n");
else
printf("pressed]\n");
delay(100); // wait 100 ms for the next reading
}