/* DEMO92.c: Shows how to use the StopWatch function on channel 0 to switch the LED ON or OFF. Compiler: BC++ 3.1, Turbo C ++ 1.01(3.01) (free from http://community.borland.com/museum) MSC 6.0, MSVC 1.52. Compile mode: Large Project: DEMO92.c ..\..\Lib\7188el.Lib Hardware: 7188E Note: Function used: TimerOpen --> begin to use I-7188 timer TimerClose --> stop to use timer StopWatchStart --> start to count time interval StopWatchReadValue -->to decide if time is up. Use StopWatch to count 500ms(0.5s) to turn LED ON or OFF. [04/Dec/2006] by Liam [July,13,2011] by Nicholas */ #include #include "..\..\lib\7188e.h" /* you must change this lib to suit the hardware that you want to use. */ void main(void) { int LedMode=0; unsigned long value; int quit=0; Print("\n\rTest StopWatch ..."); Print("\n\rNow LED must flash once every second"); Print("\n\rPress 'q' to quit\n\r"); TimerOpen(); LedOff(); StopWatchStart(0); while(!quit) { if(Kbhit()) { switch(Getch()) { case 'q': quit=1; break; } } StopWatchReadValue(0, &value); if(value>=500) { StopWatchStart(0); if(LedMode) { LedMode=0; LedOff(); } else { LedMode=1; LedOn(); } } } TimerClose(); LedOn(); }