forked from c4ev3/ev3duder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
moveEv3.pl
executable file
·41 lines (38 loc) · 1.12 KB
/
moveEv3.pl
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
#!/usr/bin/perl
use Curses;
use IPC::Open2;
print open2(\*EV3OUT, \*EV3IN, "ev3 tunnel") or die "couldn't find: %!";
my $ch = 0;
initscr, noecho, cbreak;
eval { keypad(1) };
addstr(0, 0, "press an arrow key on your keyboard: ");
refresh();
while (1)
{
$ch = getch();
addstr(2, 0, " ");
if ($ch == KEY_UP) { addstr(2, 0, "CHARGE!");
print EV3IN "0900xxxx8000 00 A3 00 09 00\n";
print EV3IN "0C00xxxx8000 00 A4 00 09 50 A6 00 09\n";
}
elsif ($ch == KEY_SPACE) { addstr(2, 0, "STOP!");
print EV3IN "0900xxxx8000 00 A3 00 09 00\n";
}
elsif ($ch == KEY_LEFT) { addstr(2, 0, "LEFT!");
print EV3IN "0900xxxx8000 00 A3 00 09 00\n";
print EV3IN "0C00xxxx8000 00 A4 00 08 50 A6 00 08\n";
}
elsif ($ch == KEY_RIGHT) { addstr(2, 0, "RIGHT!");
print EV3IN "0900xxxx8000 00 A3 00 09 00\n";
print EV3IN "0C00xxxx8000 00 A4 00 01 50 A6 00 01\n";
}
elsif ($ch == KEY_DOWN) { addstr(2, 0, "RETREAT!");
print EV3IN "0900xxxx8000 00 A3 00 09 00\n";
print EV3IN "0C00xxxx8000 00 A3 00 09 B0 A6 00 09\n";
}
refresh;
}
END {endwin}
sub motor
{
}