News Center

Current Location:Home page  <  Product Tutorials
[Product Evaluation] Picoboard controls character movement through PS2 joystick

The Picoboard sensor expansion board can be used in perfect conjunction with the official Scratch 2.0. The hardware and software interaction can be done via the USB cable. No third-party software is required. It has on-board high-precision light sensor, slider potentiometer, sound sensor, button. And four analog input interfaces for connecting a variety of analog and digital sensors. For example: mini obstacle avoidance sensor, mini line finder sensor, flame sensor, etc. A simple case to introduce to you here is to use Picoboard and PS2 game joystick to control the movement of the character and the orientation of the character.

Use hardware:
  ● Picoboard sensor expansion board * 1
  ● 7.4V 1300mAh lithium battery * 1
  ● UBEC 5V 3A * 1
  ● Breadboard * 1
  ● Jumper * Several


Wiring instructions:

* Picoboard sensor A port crocodile clip one of the B pins of the PS2 joystick

* Picoboard sensor One of the B alligator clips is connected to the x pin of the PS2 joystick

* Picoboard sensor C port crocodile clip one of the y pins of the PS2 joystick

* Picoboard sensor expansion board A, B, C interface Alligator clips are connected together and connected to the negative pole of the power supply

* The + pin of the PS2 joystick is connected to the UBEC output interface +

* PS2 joystick - pin connected to the UBEC output interface -


Hardware connection diagram:


Physical connection diagram:



Scratch example program:


After the program runs, the position of the character will move with the joystick rotation. In the upper left corner of the stage, the values read by the three analog interfaces A, B, and C will also be displayed. The principle of the experiment is to read the output value of the PS2 joystick module through the four analog input interfaces on the Picoboard, and then give this value to the character position and the angle of the face. The variables are created in the program for real-time observation. Changes in data.


This is just a simple character motion control example program. Do you have better ideas for controlling the x, y coordinates and orientation of the character by changing the x, y, and z axis values of the PS2 joystick? Let's try it!


   Create source maker, creative from ALSROBOT