I´m a beginner in using the raspberry pi. I am trying to set up a button to turn on an image and have a black screen, if the button is not pushed.
To start with simple Code, I startet with changing between two color:
black = button not pushed
red = button pushed
BUT always when the button is bushed a flickering between both colors starts. What did I do wrong? I believe the wiring is right, because it is very simple (GND & GPIO 17).
No R-pi here to test. One approach is to update only when you detect a change of button state. You continuosly check if the button is pressed. If it changes to pressed, update your memory field, update your background and keep checking. If you detect a change, the button is disengaged, you update your memory field, you change the background, and you keep checking.
The memory field could be something as simple as a boolean variable in the global scope.
Another approach is to use noLoop()/redraw() approach. Check the reference to understand their implementations.
haha, that was too easy.
That’s ok if you are a beginner, but have you ever think about controlling raspberry pi using WhatsApp?
Try to do the same light experiment by sending a command to raspberry pi using WhatsApp.
You can take help from this Control Raspberry pi with whatsapp