birv2
Raspberry Pi Certified Educator
Raspberry Pi Certified Educator
Posts: 101
Joined: Sat May 16, 2015 2:07 pm

Programming joystick in Sense HAT w/ Scratch?

Tue Jun 14, 2016 6:19 pm

Did a search on this and nothing came up.....

Is it possible to control the joystick on the Sense HAT through Scratch? I've done it with Python but I'm planning on aiming this at beginning coders so Scratch seems a better fit at that level.

EDIT: looks like it is possible (https://www.raspberrypi.org/documentati ... /README.md). Has anyone tried it successfully?

TIA,
Bob Irving

MarcScott
Raspberry Pi Foundation Employee & Forum Moderator
Raspberry Pi Foundation Employee & Forum Moderator
Posts: 81
Joined: Sat Aug 08, 2015 11:30 am

Re: Programming joystick in Sense HAT w/ Scratch?

Wed Jun 15, 2016 7:01 am

Yes, the Sense HAT joystick just maps to the cursor keys, so just using a `when up arrow key pressed` block, for instance, will let Scratch detect the use of the joystick.

birv2
Raspberry Pi Certified Educator
Raspberry Pi Certified Educator
Posts: 101
Joined: Sat May 16, 2015 2:07 pm

Re: Programming joystick in Sense HAT w/ Scratch?

Wed Jun 15, 2016 12:17 pm

Awesome. Thanks!

ghp
Posts: 1146
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: Programming joystick in Sense HAT w/ Scratch?

Wed Jun 15, 2016 7:31 pm

Hello,
the only not very perfect point is that the central button is mapped to the 'enter' key. The enter key is also the green flag event in scratch. So it can't be used to commit input, but always restarts the scratch program.
Regards,
Gerhard

birv2
Raspberry Pi Certified Educator
Raspberry Pi Certified Educator
Posts: 101
Joined: Sat May 16, 2015 2:07 pm

Re: Programming joystick in Sense HAT w/ Scratch?

Wed Jun 15, 2016 7:38 pm

Hmm. So pushing down on the joystick in the middle position = green flag?
That could be tricky.

DavTor
Posts: 4
Joined: Wed Sep 04, 2013 12:31 pm

Re: Programming joystick in Sense HAT w/ Scratch?

Wed Aug 30, 2017 1:49 pm

Has someone tried the joystick in Scratch 2 in Debian Stretch? The sensors and the LED matrix works well, but I can not use the joystick in Scratch 2. Someone else?. Thanks

mob-i-l
Posts: 204
Joined: Sat Dec 29, 2012 2:45 am
Location: Lund, Skåne/Scania, Sweden
Contact: Website Facebook Twitter YouTube

Re: Programming joystick in Sense HAT w/ Scratch?

Wed Aug 30, 2017 6:10 pm

DavTor wrote:
Wed Aug 30, 2017 1:49 pm
Has someone tried the joystick in Scratch 2 in Debian Stretch? The sensors and the LED matrix works well, but I can not use the joystick in Scratch 2. Someone else?. Thanks
It works for me as the arrow keys events, and there is an "enter" among the keys, for the joystick press, which doesn't exist in standard Scratch 2.

E.g.

when enter key pressed

when down arrow key pressed
Raspberry Pi0&1A&1B2&1B+&2B&3B w/ Raspbian. Started w/ BASIC on ABC80&ZX81 then Forth, Z80… http://scratch.mit.edu/users/mobluse/ https://github.com/mobluse/ https://www.youtube.com/MOBiL4u/ https://twitter.com/mobluse/

DavTor
Posts: 4
Joined: Wed Sep 04, 2013 12:31 pm

Re: Programming joystick in Sense HAT w/ Scratch?

Thu Aug 31, 2017 6:42 am

SOLVED. I'm sorry. It was because of the remote desktop connection. Thanks

Return to “Scratch”

Who is online

Users browsing this forum: No registered users and 3 guests