Table of Contents
Example Description
Learn how to interface a joystick with Quarky, the versatile microcontroller, to control the movement of Quarky Robot.
Introduction

A joystick is an input device used to control the movement or actions of a computer, video game console, or other electronic device. In gaming, joysticks are often used to control the movement of characters or vehicles in a virtual environment. They provide analog input, meaning the degree of movement can vary based on how far the handle is pushed in a particular direction. In aviation and flight simulation, joysticks are commonly used to simulate the control of aircraft, providing pitch, roll, and yaw inputs. Some advanced joysticks also come with additional features such as throttle controls, programmable buttons, and force feedback to enhance the gaming or simulation experience. below is a simple animation of a joystick.

 

 

In this example, we’ll be interfacing a joystick with Quarky and try to read the values of the joystick along the x and y axis let’s begin!!

Circuit Diagram

 

 

connection

JoyStick       Quarky

GND                          GND

5V                                  V

VarX                             A1

VarY                              A2

 

Code

  1. Connect JoyStick as per the above connections.
  2. Open pictoblx and create a new file.
  3. Select Quarky from the board menu.
  4. From events palette drag when the” flag clicked “block into the scripting area.
  5. Now add a “forever ” loop from controls palette
  6. A say() block from the looks palette
  7. from the sensor palette of Quarky add “read analog sensor () at pin()”  in place of hello. and select “joystick X” at pin A1 from the dropdown. 

Now run the code, with this simple script, you will be able to read the value of the joystick along for X-axis in forward, backward, left, and right. with these values you will be able to set the logic on different values for fixing the direction as forward, backward, etc. do same for finding values for Y-axis.

Task for you.

Try to print the value of both the axis together

Output