PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Examples
Badge
02 Lights
01 Blink Lights.c
1
/*
2
Blink Lights.c
3
Use a variable as an index to repeatedly select a sequence of lights
4
for turning on/off.
5
*/
6
7
#include "
simpletools.h
"
// Include simpletools library
8
#include "
badgetools.h
"
// Include badgetools library
9
10
int
n = 0;
// Number
11
12
void
main
()
// Main function
13
{
14
badge_setup
();
// Call badge setup
15
oledprint
(
"n=012345repeats"
);
// Display
16
// n increments, and is used to select
17
// which light number is turned on/off.
18
while
(1)
// Main loop
19
{
20
led
(n,
ON
);
// Turn on light n
21
pause
(100);
// ...for 0.1 s
22
led
(n,
OFF
);
// Turn off light n
23
pause
(100);
// ...for 0.1s
24
n++;
// Increment n
25
if
(n == 6) n = 0;
// Reset if > 5
26
}
27
}
28
29
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,...
led
void led(int n, int state)
Set a blue LED (from 0 to 5) to a state (ON or OFF). Examples: led(1, ON) turns the blue LED next to ...
Definition:
leds_led.c:9
main
int main(void)
Definition:
GraphicsTest.c:20
oledprint
int oledprint(const char *fmt,...)
Use to display strings on the oLED display in a manner similar to displaying combinations of strings ...
Definition:
peb_text.c:4
badge_setup
int badge_setup(void)
Set up all available badge drivers. Call this function at the start of any given program to allow acc...
Definition:
badgealpha.c:29
badgetools.h
This library provides convenient functions for a variety of Parallax eBadge operations.
OFF
#define OFF
OFF can be used in place of zero to enabled parameters in functions like drive_feedback and drive_tri...
Definition:
abdrive.h:204
ON
#define ON
ON can be used in place of a nonzero value to enabled parameters in functions like drive_feedback and...
Definition:
abdrive.h:212
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17