-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanualcode
More file actions
44 lines (37 loc) · 1.7 KB
/
manualcode
File metadata and controls
44 lines (37 loc) · 1.7 KB
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
global key
InitKeyboard();
while 1
pause(0.1);
switch key
case 'uparrow' %For moving forward
disp('up Arrow Pressed!');
brick.MoveMotor(RMOTOR, SPEED);
brick.MoveMotor(LMOTOR, SPEED);
case 'downarrow' %For moving backward
disp('down Arrow Pressed!');
brick.MoveMotor(RMOTOR, -SPEED);
brick.MoveMotor(LMOTOR, -SPEED);
case 'leftarrow' %For turning left
disp('Left Arrow Pressed!');
brick.MoveMotor(RMOTOR, SPEED);
brick.MoveMotor(LMOTOR, -SPEED);
case 'rightarrow' %For turning right
disp('Right Arrow Pressed!');
brick.MoveMotor(RMOTOR,-SPEED);
brick.MoveMotor(LMOTOR,SPEED);
case 'w' %Raises the lift
disp('w pressed');
brick.MoveMotor(DMOTOR,5);
case 's' %Lowes the lift
disp('s pressed');
brick.MoveMotor(DMOTOR,-5);
case 0 %No key is being pressed.
disp('No Key Pressed');
brick.StopMotor('A');
brick.StopMotor('D');
brick.StopMotor('B');
case 't'
break
end
end
CloseKeyboard();