PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Examples
Robots
ActivityBot
Test IR Detectors.c
1
/*
2
Test IR Detectors.c
3
4
Test IR LEDs and IR receivers used together as object detectors.
5
6
http://learn.parallax.com/activitybot/test-ir-sensor-circuits
7
*/
8
9
#include "
simpletools.h
"
// Include simpletools
10
11
int
irLeft, irRight;
// Global variables
12
13
int
main
()
// Main function
14
{
15
low
(26);
// D/A0 & D/A1 to 0 V
16
low
(27);
17
18
while
(1)
// Main loop
19
{
20
freqout
(11, 1, 38000);
// Left IR LED light
21
irLeft =
input
(10);
// Check left IR detector
22
23
freqout
(1, 1, 38000);
// Repeat for right detector
24
irRight =
input
(2);
25
26
print
(
"%c irLeft = %d, irRight = %d"
,
// Display detector states
27
HOME
, irLeft, irRight);
28
pause
(100);
// Pause before repeating
29
}
30
}
31
HOME
#define HOME
HOME character (1) sends SimpleIDE Terminal's cursor to top-left "home" position.
Definition:
simpletools.h:233
freqout
void freqout(int pin, int msTime, int frequency)
Use same cog to send square wave of a certain frequency for a certain amount of time....
Definition:
freqout.c:10
pause
void pause(int time)
Delay cog from moving on to the next statement for a certain length of time.
Definition:
libws2812.c:125
low
void low(int pin)
Set an I/O pin to output-low.
Definition:
low.c:19
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
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.
main
int main(void)
Definition:
GraphicsTest.c:20
input
int input(int pin)
Set an I/O pin to input and return 1 if pin detects a high signal, or 0 if it detects low.
Definition:
input.c:19
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17