I don’t find a tutorial to configure them with scratch…
So, like a button, i do :
Broadcast (join(analogread,0))
But I receive juste one value, the X value I think.
But I need Y value too.
On this Website, I see the python code. The two analog Pins A0 and A1 are used for that in the Grove Cards.
But how can I declare and catch this two values on Scratch ?
I tried
Broadcast (join(analogRead,0))
Broadcast (join(analogRead,1))
But the only value is analogRead…
Thanks for the help and excuse me for my bad english
Hi,
It works fine for me. With one Joystick. It’s cool.
The problem is that I need two Joystick. I thought I could plug the second
one on the A2 port, but there will be a conflict with the analogRead
variable.
Is it possible to do that ?
Hi,
The problem is the analogRead sensor value.
If the two joystick are pushed at the same time, there is just one value of
analogRead. So it’s the first which is written…
Thanks for the help
.
In fact, when the Grove Card (Port A0 and A1) receive the position of X or
Y of the first Joystick, Scratch put the value in the variable analogRead.
There is just one variable for both X or Y.
You resolve my problem with a little timer.
But if i use a second joystick (port A2 et A3), it will use exactly the
same analogRead variable to write the value of its X or Y.
So if I push up the two joystick in the same time (I do a game so it will
be possible), the analogRead variable will take the first value it will
have…
@johan.guillot
it’s the nature of this type of communications. Only one can be accessed at a time, so we have to fake simultaneous reads.
One way is to have a tight forever loop that does just the readings. Reactions to those readings are done outside of the loop. (note the mapping approach I used to match joystick readings to screen position is extremely crude)
You can play with the delay value to make the loop as tight as you can. Don’t make it too tight as it will overwhelm the Scratch controller running in the background. 0.1 sec works, but you could try 0.05 sec too