PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Examples
Devices
Sensor
ColorPAL
Test ColorPAL.c
1
/*
2
Test ColorPAL.c
3
4
Test Parallax ColorPAL sensor.
5
6
Connect: sig to P6, +5V to 5V, Gnd to GND
7
8
http://www.parallax.com/product/28380
9
*/
10
11
#include "
simpletools.h
"
// Include simpletools
12
#include "
colorpal.h
"
// Include colorpal
13
14
colorPal *cpal;
// Device identifier
15
int
cpSIO = 6;
// ColorPAL SIO -> Propeller P6
16
int
r, g, b;
// Variables for red, green, blue
17
18
int
main
()
// Main function
19
{
20
cpal =
colorPal_open
(cpSIO);
// Open connection to ColorPAL
21
22
while
(1)
// Main loop
23
{
24
colorPal_getRGB
(cpal, &r, &g, &b);
// Get red/green/blue readings
25
26
print
(
"r = %04d g = %04d b = %04d\n"
,
// Display red/green/blue readings
27
r, g, b);
28
29
pause
(1000);
// 1 s before repeat
30
}
31
}
colorPal_getRGB
void colorPal_getRGB(colorPal *device, int *r, int *g, int *b)
Get RGB (red green blue) values from the ColorPAL sensor.
Definition:
colorpal.c:47
pause
void pause(int time)
Delay cog from moving on to the next statement for a certain length of time.
Definition:
libws2812.c:125
colorpal.h
Simplifies reading Parallax ColorPAL sensor.
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
colorPal_open
colorPal * colorPal_open(int sioPin)
Open a connection to a Parallax ColorPAL sensor.
Definition:
colorpal.c:79
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17