forked from theZiz/ev3c
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_led.c
81 lines (61 loc) · 2.24 KB
/
test_led.c
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
70
71
72
73
74
75
76
77
78
79
80
81
/*
The contents of this file are subject to the "do whatever you like"-license.
That means: Do, whatver you want, this file is under public domain. It is an
example for ev3c. Copy it and learn from it for your project and release
it under every license you want. ;-)
For feedback and questions about my Files and Projects please mail me,
Alexander Matthes (Ziz) , ziz_at_mailbox.org, http://github.com/theZiz
*/
#include "ev3c.h"
#include <stdio.h>
int main(int argc,char** argv)
{
ev3_init_lcd();
ev3_init_button();
ev3_init_led();
ev3_clear_lcd();
ev3_text_lcd_normal(0,EV3_Y_LCD-9,"Press < to continue");
ev3_text_lcd_small(0,0,"Left LED green");
ev3_set_led(LEFT_LED,GREEN_LED,255);
while (!ev3_button_pressed(BUTTON_LEFT));
while (ev3_button_pressed(BUTTON_LEFT));
ev3_text_lcd_small(0,17,"Right LED red");
ev3_set_led(RIGHT_LED,RED_LED,255);
while (!ev3_button_pressed(BUTTON_LEFT));
while (ev3_button_pressed(BUTTON_LEFT));
ev3_text_lcd_small(0,34,"All LEDs half power");
ev3_set_led(LEFT_LED,GREEN_LED,127);
ev3_set_led(RIGHT_LED,RED_LED,127);
while (!ev3_button_pressed(BUTTON_LEFT));
while (ev3_button_pressed(BUTTON_LEFT));
ev3_text_lcd_small(0,51,"All LEDs swap");
ev3_set_led(LEFT_LED,GREEN_LED,0);
ev3_set_led(RIGHT_LED,RED_LED,0);
ev3_set_led(LEFT_LED,RED_LED,127);
ev3_set_led(RIGHT_LED,GREEN_LED,127);
while (!ev3_button_pressed(BUTTON_LEFT));
while (ev3_button_pressed(BUTTON_LEFT));
ev3_text_lcd_small(0,68,"All LEDs off");
ev3_set_led(LEFT_LED,RED_LED,0);
ev3_set_led(RIGHT_LED,GREEN_LED,0);
while (!ev3_button_pressed(BUTTON_LEFT));
while (ev3_button_pressed(BUTTON_LEFT));
ev3_text_lcd_small(0,85,"All LEDs amber");
ev3_set_led(LEFT_LED,GREEN_LED,255);
ev3_set_led(RIGHT_LED,RED_LED,255);
ev3_set_led(LEFT_LED,RED_LED,255);
ev3_set_led(RIGHT_LED,GREEN_LED,255);
while (!ev3_button_pressed(BUTTON_LEFT));
while (ev3_button_pressed(BUTTON_LEFT));
ev3_text_lcd_small(0,102,"All LEDs yellow");
ev3_set_led(LEFT_LED,GREEN_LED,255);
ev3_set_led(RIGHT_LED,RED_LED,25);
ev3_set_led(LEFT_LED,RED_LED,25);
ev3_set_led(RIGHT_LED,GREEN_LED,255);
while (!ev3_button_pressed(BUTTON_LEFT));
while (ev3_button_pressed(BUTTON_LEFT));
ev3_quit_button();
ev3_quit_led();
ev3_quit_lcd();
return 0;
}