This example shows how to use the Mindsensors PSP device to read left and right joysticks.
"PSP stick demo" "lib/modules/standard.whl" "lib/modules/device.whl" "lib/modules/sensor.whl" "lib/modules/screen.whl" "lib/modules/psp.whl" "EV3, PSP" proc drawLeftPosition(number x, number y) drawCircle(46 + x / 5, 64 + y / 5, 10) end proc drawRightPosition(number x, number y) drawCircle(132 + x / 5, 64 + y / 5, 10) end proc main() ; Select the EV3 device in the simulator... selectDevice(DEVICE_EV3) pspStart(INPUT_1) drawLeftPosition(0, 0) drawCircle(46, 64, 40) drawRightPosition(0, 0) drawCircle(132, 64, 40) updateScreen() number lastLeftX = 0 number lastLeftY = 0 number lastRightX = 0 number lastRightY = 0 repeat number leftX = pspData.stickLeftX number leftY = pspData.stickLeftY number rightX = pspData.stickRightX number rightY = pspData.stickRightY if leftX != lastLeftX or leftY != lastLeftY setFillColor(WHITE) drawLeftPosition(lastLeftX, lastLeftY) setFillColor(BLACK) drawLeftPosition(leftX, leftY) updateScreen() lastLeftX = leftX lastLeftY = leftY end if rightX != lastRightX or rightY != lastRightY setFillColor(WHITE) drawRightPosition(lastRightX, lastRightY) setFillColor(BLACK) drawRightPosition(rightX, rightY) updateScreen() lastRightX = rightX lastRightY = rightY end end end