PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Examples
Robots
ActivityBot
Test Light Sensors Graphical.c
1
/*
2
Test Light Sensors Graphical.c
3
4
http://learn.parallax.com/activitybot/using-measurements
5
*/
6
7
#include "
simpletools.h
"
8
9
10
int
lightLeft, lightRight, ndiff, position;
11
12
int
main
()
13
{
14
print
(
"lightLeft lightRight ndiff\n\n\n\n"
);
15
print
(
"|------------------------|------------------------|\n"
);
16
print
(
"-100 0 100\n"
);
17
char
s[51] = {
" "
};
18
19
while
(1)
20
{
21
high
(9);
22
pause
(1);
23
lightLeft =
rc_time
(9, 1);
24
25
high
(5);
26
pause
(1);
27
lightRight =
rc_time
(5, 1);
28
29
ndiff = 200 * lightRight / (lightRight + lightLeft) - 100;
30
31
print
(
"%c%c"
,
HOME
,
CRSRDN
);
32
print
(
"%d %d %d"
, lightLeft, lightRight, ndiff);
33
print
(
"%c%c%c"
,
CLREOL
,
CRSRDN
,
CR
);
34
35
position = (ndiff + 100) / 4;
36
s[position] =
'*'
;
37
print
(s);
38
s[position] =
' '
;
39
40
pause
(350);
41
}
42
}
HOME
#define HOME
HOME character (1) sends SimpleIDE Terminal's cursor to top-left "home" position.
Definition:
simpletools.h:233
pause
void pause(int time)
Delay cog from moving on to the next statement for a certain length of time.
Definition:
libws2812.c:125
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
CR
#define CR
CR character (13) sends SimpleIDE Terminal's cursor one row downward.
Definition:
simpletools.h:339
print
int print(const char *format,...) __attribute__((format(printf
Print format "..." args to the default simple terminal device. The output is limited to 256 bytes.
CRSRDN
#define CRSRDN
CRSRDN character (6) sends the SimpleIDE Terminal's cursor one row (carriage return) downward from it...
Definition:
simpletools.h:275
main
int main(void)
Definition:
GraphicsTest.c:20
rc_time
long rc_time(int pin, int state)
Set I/O pin to input and measure the time it takes a signal to transition from a start state to the o...
Definition:
rcTime.c:19
CLREOL
#define CLREOL
CLREOL character (11) erases all SimpleIDE Terminal characters to the right of the cursor.
Definition:
simpletools.h:323
high
void high(int pin)
Set an I/O pin to output-high.
Definition:
high.c:19
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17