Arduino Joystic Protocol
This protocol shows information of an analog joystick connected to the microcontroller.
ONLY IF the status of the joystick changes, the device sends a
'joystick_changed' event to the .Net.
How to build a test circuit with an Analog Joystick and an Arduino Mega?
Arduino codes are included.
I. "Welcome" event from microcontroller
Example
//Analog Joystick
c=welcome&type=OzAnalogJoystickController&pos=2&id=AAA000&t=3
Parameters
Parameter |
Type |
Range |
Functionality |
c |
String |
"welcome" |
Identifies the welcome message. |
type |
String |
"OzAnalogJoystickController" |
Determines the type of the device. |
pos |
Byte |
0-255 |
Determines the position of the device on the list of the ID manager of the microcontroller.
Please make sure there are no other devices in the same position. |
id |
String |
6 characters (numbers, uppercase and lowercase characters) |
The ID of the device which is chosen by the microcontroller. |
t |
Byte |
0-255 |
Counts the number of events and responses sent combined. Counts from 0 to 255 then from 0 again. |
II. Commands to microcontroller
"reset_joystick" command
Resets the centerpoint of the joystick on the microcontroller's end. You should only reset your joystick if it is not used.
Example
c=reset_joystick&id=AAA000&t=1
Parameters
Parameter |
Type |
Range |
Functionality |
c |
String |
"reset_joystick" |
Identifies the command. |
id |
String |
6 characters (numbers, uppercase and lowercase characters) |
The ID of the device which is chosen by the microcontroller. |
t |
Byte |
0-255 |
Counts the number of commands sent. Counts from 0 to 255 then from 0 again. |
Response
Sends a response if the joystick reset has been completed.
Example
c=reset_resp&id=AAA000&t=3
Parameter |
Type |
Range |
Functionality |
c |
String |
"reset_resp" |
Identifies the command. |
id |
String |
6 characters (numbers, uppercase and lowercase characters) |
The ID of the device which is chosen by the microcontroller. |
t |
Byte |
0-255 |
Counts the number of events and responses sent combined. Counts from 0 to 255 then from 0 again. |
III. Event from microcontroller
"joystick_changed" event
This event is called if the joystick moves or the top button is pressed or released.
Example
c=joystick_changed&x=112&y=164&button=1&id=AAA000&t=4
Parameters
Parameter |
Type |
Range |
Functionality |
c |
String |
"joystick_changed" |
Identifies the command. |
x |
Byte |
0 to 255 |
The x coordinate of the current position. |
y |
Byte |
0 to 255 |
The y coordinate of the current position. |
button |
Bool |
0,1 |
Button's state. 1 if pressed, 0 if released. |
id |
String |
6 characters (numbers, uppercase and lowercase characters) |
The ID of the device which is chosen by the microcontroller. |
t |
Byte |
0-255 |
Counts the number of events and responses sent combined. Counts from 0 to 255 then from 0 again. |