Manual

Table Of Contents
Arduino Kit Demo Description 9 JoyStick Demo
Issue V2.1 (2019-12-05) Demo Description Copyright © Yuejiang Technology Co., Ltd
30
Initialization.
Program 9.2 Initialization
void setup()
{
Dobot_Init();
SmartKit_Init();
}
Define the moving direction of Dobot Magician and the air pump start-stop based
on the moving direction of joystick and buttons.
NOTE
When moving joystick along X-axis or Y-axis, the analog values change from 0 to 1023,
as shown Figure 9.4. The homing position of the joystick is at (x,y: 512,508).
Figure 9.4 Value range
Program 9.3 Define the moving direction of Dobot Magician based on joystick and buttons
int x = 0,y = 0,z = 0,b1 = 0,b2 = 0,b3 = 0;
int direction = 0; //Define direction of JoyStick
x = SmartKit_JoyStickReadXYValue(AXISX);
y = SmartKit_JoyStickReadXYValue(AXISY);
z = SmartKit_JoyStickCheckPressState();
b1 = SmartKit_ButtonCheckState(RED);
b2 = SmartKit_ButtonCheckState(GREEN);
b3 = SmartKit_ButtonCheckState(BLUE);
if(y > 600){ //JoyStick moves alongt Y-axis in the positive direction
direction = 1;
}