#include <12f629.h> #case /*----------------------------------------------------------------------------*/ #use delay( clock = 4000000 ) #fuses NOWDT, PROTECT, INTRC_IO, NOMCLR, BROWNOUT, CPD typedef unsigned int uint8; typedef short bool; typedef unsigned long uint16; #define false 0 #define true 1 #define TRIGGER PIN_A0 // input (active low) #define DIP PIN_A1 // input (active low) #define LED PIN_A2 // output // high-green #define FET_1 PIN_A4 // output (active high) #use fast_io( A ) int cycleOn; int cycleOff; int cycleBox; //------------------------------------------------------------------------------ void main() { // same I/O map for mini and original (nifty, eh?) set_tris_a( 0x0B ); // setup I/O bus OO|IOII output_high( LED ); // turn ON LED output_low( FET_1 ); // turn off FETs setup_comparator( NC_NC ); setup_counters( RTCC_INTERNAL, RTCC_DIV_2 ); // 1960 ints/sec port_a_pullups( 0x03 ); cycleOn = 20; cycleOff = 236; cycleBox = 0; for(;;) { if ( input(TRIGGER) ) { output_high( LED ); // turn ON LED output_high( FET_1 ); for( cycleBox=0 ; cycleBox < cycleOn ; cycleBox++ ); output_low( FET_1 ); for( cycleBox=0 ; cycleBox < cycleOff ; cycleBox++ ); } output_low( LED ); // turn OFF LED output_low( FET_1 ); } }