Discuss Scratch

POKEGAMERZ9185
New to Scratch
3 posts

Raspberry Pi GPIO Button not working

I am working on a Raspberry Pi Pong console and programming the GPIO pins on Scratch. Everything works, but 1 of my buttons is having a problem. The other 3 buttons connected to the Raspberry Pi work and cause the paddle to move while pressing the button. I even tested the sensor value for the button (GPIO 26) and the 1 turns to 0 when the button is pressed. Please give me suggestions on how to fix this since this does not happen with the other buttons connected to the GPIO pins.
POKEGAMERZ9185
New to Scratch
3 posts

Raspberry Pi GPIO Button not working

Also if there is a way to attach a picture, please let me know because I have a picture of the connection.

Here is the code for the paddle:

when green flag clicked
broadcast [ gpioserveron]
broadcast [ config27in]
broadcast [ config26in]
go to x: (200) y: (0)
forever
if <[gpio27 sensor value] = [0]> then
change y by (5)
if <[gpio26 sensor value] = [0]> then
change y by (-5)

end
end
end

This is the code for the paddle having the button problem. The up button (GPIO 27) works well, but the down button (GPIO 26) does not work even though the sensor value changes from 1 to 0 when pressed like it is supposed to.
SimpleScratch
Scratcher
500+ posts

Raspberry Pi GPIO Button not working

You need to move

if gpio26 sensor value = 0 then
change y by -5

so that it isn't inside the other if statement

it needs to follow the first if
POKEGAMERZ9185
New to Scratch
3 posts

Raspberry Pi GPIO Button not working

SimpleScratch wrote:

You need to move

if gpio26 sensor value = 0 then
change y by -5

so that it isn't inside the other if statement

it needs to follow the first if
Oops. Looks like I haven't noticed. I was doing this really late at night and was pretty tired. I spent hours assuming it was a problem with the connection. I'll just fix the code and let you know what happens
SimpleScratch
Scratcher
500+ posts

Raspberry Pi GPIO Button not working

I was doing this really late at night and was pretty tired. I spent hours assuming it was a problem with the connection
We've all been there and done that!

A good nights sleep cures a LOT of programming errors

Powered by DjangoBB