[DIY117]

Do it yourself !


 

HOWTO Make a Digital Drawing Board with an old joystick in 5 minutes!

Video:

 

Parts List:

1 CUBLOC CB280
1 GHLCD Graphic LCD
1 Old Analog Joystick
Couple wires

HOWTO

Time to do: About 5 minutes plus time it takes to take a joystick apart.

(I was able to skip this part as Garret gave me a joystick that was taken apart already.

Today, Garret, my new co-worker, gave me couple of old analog
joysticks he had lying around that was from old rc controllers.


Well an idea hit me and I pondered what I can make that would be
easy and fast but would be useful.


I decided I could simply read the analog values using a CUBLOC module
and make a digital drawing board.

So I had 3 joysticks to choose from.  I figured on the one that is on the most right from the above picture.

I've never worked with joysticks before, but I noticed that all the joysticks
had 3 outputs like shown above.
Garret explained to me that the left pin is for ground, the right pin is for VCC (5V), and the middle pin is an analog output for the axis.
I noticed that there are two axises, X and Y on these joysticks.

 

WIthout any delay, I soldered two wires for the Ground and VCC so I
only have to power one axis to power both axises.
The Blue wire above is Ground and Red wire is the VCC.

Next, I wired a yellow wire for the Ground and VCC plus a wire for each
analog output of each axis.

Next, I simply plugged in Ground wire to Ground of the Study Board,
VCC wire to 5V of the Study Board, X Axis wire to P25 (analog channel 1)
of the Study Board, and Y Axis wire to P24 (analog channel 0) of the Study Board.

View from the top side is shown here:

Next I made a simple program that would receive inputs:

Const Device = CB280

 

Dim a As Integer

Dim b As Integer

 

Input 24

Input 25

 

Do

    a=Adin(0)

    b=Adin(1)

    Debug "Up & Down Value: ", Dec a,Cr

    Debug "Left & Right Value: ", Dec b,Cr

    Delay 100

Loop

 

This program prints the value of the X and Y analog outputs of the joystick.
Since I didn't know what analog voltage I was supposed to receive,

I simply ran the program and noted the analog input values when the
Joystick was in the center, left, right, down, and up.

Now with those values, I could calibrate my program to know when to move
the cursor to the left, right, up, and down.

Here is part of the BASIC code for the XAxis:

 

#define XCENTER 270

#define XLEFT 375

#define XRIGHT 148

 

If X > XCENTER -10 And X < XCENTER +10 Then

     'do nothing

Elseif X > XCENTER+10 Then

      'move left

      MLeft

Elseif X < XCENTER-10 Then

     MRight

End If

 

MLeft and MRight are sub functions that will simply re-draw the cursor about 8 pixels to the left and right.

I would give about value of 10 (AD input returns a value between 0 to 1024
for voltage between 0 and 5V), as a safety value for debouncing and shakes.

Likewise, I made similar functions for up, down, and diagonal directions.

Download JoyStick Program  here

Well you can download the JoyStick Program using CublocStudio and see this initial screen:

 

Completed Look of the Digital Drawing Board:

 

You can use the pushbutton on the Study Board to draw!

 

 

 

Taking it Further...

Yes, you could use these old joysticks for anything like a remote-controlled robot, drawing board, or anything that requires left, right, up, and down buttons.

Next time, we will see if we can make a bluetooth joystick...

<:)

 

 

If you are having any trouble with above app, please e-mail max@zedomax.com

If you have any cool apps you'd like to share or want some kind of DIY, please e-mail to max@zedomax.com

We do accept free samples for DIYs, please email  max@zedomax.com :)