PropWare
C++ objects and CMake build system for Parallax Propeller
Home
Download
Getting Started
Documentation
Reference
About
Related Links
Namespace List
Class List
File List
Examples
Build System
File List
File Members
propsideworkspace
Learn
Examples
Devices
Sensor
Sound Impact
SoundImpactSensor Simple.c
1
/*
2
SoundImpactSensor Simple.c
3
4
This sensor can be monitored repeatedly, and with a relatively small
5
interval to check for sounds. The sensor's SIG pin sends a high signal
6
if sound is detected, or a low if not. Since SIG is connected to P4,
7
input(4) will return 1 if detected, or 0 if not.
8
9
Connect: SIG to (R = 2.2 k) to P4, 5V to 5V, GND to GND
10
11
http://www.parallax.com/product/29132
12
*/
13
14
#include "simpletools.h"
// Include simpletools
15
16
int
main
()
// Main function
17
{
18
while
(1)
// Main loop
19
{
20
print(
"%c"
, HOME);
// Cursor -> top-left
21
if
(input(4))
// Sensor high (detected)
22
{
23
print(
"Sound impact detected!%c"
, CLREOL);
// Display detected message
24
pause(1000);
// Wait for user to see it
25
}
26
else
// Sensor low (not detected)
27
{
28
print(
"Waiting for sound...%c"
, CLREOL);
// Display waiting message
29
}
30
pause(50);
// Slow down for terminal
31
}
32
}
main
int main(void)
Definition:
GraphicsTest.c:20
Generated on Sat Aug 27 2016 00:58:03 for PropWare by
1.8.12