-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtoggleLaserFlag.c
More file actions
57 lines (50 loc) · 1.47 KB
/
toggleLaserFlag.c
File metadata and controls
57 lines (50 loc) · 1.47 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
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
Program to tell the servo to rotate so that it will block the laser.
This is mainly example code so that you can see how to implement it
in a different program that you write.
*/
#include <stdlib.h>
#include <stdio.h>
#include <wiringPi.h>
#include "interfacing/laserFlag.h"
#include "interfacing/kenBoard.h"
int main (int argc, char *argv[])
{
unsigned short value,device;
if (argc==2) {
device = atoi(argv[1]);
}else{
printf("Usage ./toggleLaserFlag <device 0,1>\n");
printf("Switches the blocked state for the\n");
printf("unblocked and vice-versa.\n");
printf("Device\n");
printf("======\n");
printf("Probe = 0\n");
printf("Pump = 1\n");
return 1;
}
initializeBoard();
delay(300);
switch (device) {
case 1:
value=getFlag(PUMPFLAG);
if(value>0){value=0;}else{value=8;}
setFlag(PUMPFLAG,value);
delay(300);
value=getFlag(PUMPFLAG);
if(value>0){printf("Pump Laser blocked\n");}else{printf("Pump Laser unblocked\n");}
break;
case 0:
value=getFlag(PROBEFLAG);
if(value>0){value=0;}else{value=8;}
setFlag(PROBEFLAG,value);
delay(300);
value=getFlag(PROBEFLAG);
if(value>0){printf("Probe Laser blocked\n");}else{printf("Probe Laser unblocked\n");}
break;
default:
printf("invalid device number\n");
break;
}
return 0;
}