PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Examples
Devices
Sensor
Sound Impact
SoundImpactSensor OtherCog.c
1
/*
2
SoundImpactSensor OtherCog.c
3
4
Monitors and tracks number of sound impacts from another cog.
5
It's an extravagant use of a cog, but will simplify tracking if
6
the application has enough cogs available.
7
8
Connect: SIG to (R = 2.2 k) to P4, 5V to 5V, GND to GND
9
10
http://www.parallax.com/product/29132
11
*/
12
13
#include "
simpletools.h
"
// Include simpletools
14
#include "
soundimpact.h
"
// Include soundimpact
15
16
int
main
()
// Main function
17
{
18
print
(
"Tracks sound impacts and \n"
);
// User prompt
19
print
(
"updates every 3 seconds.\n"
);
20
21
soundImpact_run
(4);
// Run in other cog
22
23
while
(1)
// Endless main loop
24
{
25
int
count
=
soundImpact_getCount
();
// Get impact count
26
print
(
"count = %d\n"
,
count
);
// Display
27
pause
(3000);
// Wait 3 seconds
28
}
29
}
30
soundImpact_getCount
int soundImpact_getCount(void)
Get number of impacts since last call to soundImpact_getCount.
Definition:
soundimpact.c:31
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,...
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
soundimpact.h
Monitor sound impact occurrences from another cog. IMPORTANT: This library is only for making moni...
count
long count(int pin, long duration)
Count number of low to high transitions an external input applies to an I/O pin over a certain period...
Definition:
count.c:19
soundImpact_run
int * soundImpact_run(int pin)
Runs the sound impact tracking process in another cog.
Definition:
soundimpact.c:19
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17