PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Examples
Robots
ActivityBot
Test Whiskers with LEDs.c
1
/*
2
Test Whiskers with LEDs.c
3
4
Display whisker states in terminal. 1 = not pressed, 0 = pressed.
5
6
http://learn.parallax.com/activitybot/add-whisker-indicator-lights
7
*/
8
9
#include "
simpletools.h
"
// Include simpletools header
10
11
int
main
()
// main function
12
{
13
freqout
(4, 2000, 3000);
// Speaker tone: P4, 2 s, 3 kHz
14
while
(1)
// Endless loop
15
{
16
int
wL =
input
(7);
// Left whisker -> wL variable
17
int
wR =
input
(8);
// Right whisker -> wR variable
18
if
(wL == 0)
high
(26);
else
low
(26);
// Light for left whisker
19
if
(wR == 0)
high
(27);
else
low
(27);
// Light for right whisker
20
print
(
"%c"
,
HOME
);
// Terminal cursor home (top-left)
21
print
(
"wL = %d wR = %d"
, wL, wR);
// Display whisker variables
22
pause
(50);
// Pause 50 ms before repeat
23
}
24
}
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
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