forked from Cryocrat/LeonardoJoystick
-
Notifications
You must be signed in to change notification settings - Fork 0
/
leoJoy.ino
69 lines (47 loc) · 937 Bytes
/
leoJoy.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
Arduino Leonardo Joystick!
*/
JoyState_t joySt;
void setup()
{
pinMode(13, OUTPUT);
joySt.xAxis = 0;
joySt.yAxis = 0;
joySt.zAxis = 0;
joySt.xRotAxis = 0;
joySt.yRotAxis = 0;
joySt.zRotAxis = 0;
joySt.throttle = 0;
joySt.rudder = 0;
joySt.hatSw1 = 0;
joySt.hatSw2 = 0;
joySt.buttons = 0;
}
void loop()
{
joySt.xAxis = random(255);
joySt.yAxis = random(255);
joySt.zAxis = random(255);
joySt.xRotAxis = random(255);
joySt.yRotAxis = random(255);
joySt.zRotAxis = random(255);
//joySt.throttle = random(255);
joySt.rudder = random(255);
joySt.throttle++;
joySt.buttons <<= 1;
if (joySt.buttons == 0)
joySt.buttons = 1;
joySt.hatSw1++;
joySt.hatSw2--;
if (joySt.hatSw1 > 8)
joySt.hatSw1 = 0;
if (joySt.hatSw2 > 8)
joySt.hatSw2 = 8;
delay(100);
if (joySt.throttle > 127)
digitalWrite(13, HIGH);
else
digitalWrite(13, LOW);
// Call Joystick.move
Joystick.setState(&joySt);
}