The harder you work, |
Please refer to the buttonsLeds.bas file included in the project’s zip file during the remainder of this discussion as its code comments contain a much more complete description of this application then space allows here. The code begins by defining compiler directives used by the hardware A/D, PWM and PULSIN circuitry. Beginning at line 18, the I/O pins are assigned to the PIC’s ports. Next, it declares several MAX/MIN constants used to distinguish demodulated SIRC pulses (start, zero, one) as well as command sequences for the LCD. Each device has its own “driver” code that consists of “*Init”, “*Read” and/or “*Paint” routines (eg. prSensorInit, prSensorRead). The application’s main logic consists of an “Init” routine, which calls all of the device “*Init” routines. This is followed by the “MainLoop” routine, which calls device “*Read” routines, then “compInDev” and “compSel” routines, and finally the “*Paint” routines. It then pauses before repeating infinitely. The “compInDev” routine computes which input device, the photoresistor or the SIRC device, to use as input. Finally, the “compSel” routine computes the selected direction (reads the button state), and calculates the duty cycle for the motor. |
6 of 6
|
www.MichaelDWelch.net MichaelDWelch@(no-spam)acm.org www.linkedIn.com/in/MichaelDWelch 303-920-9749 remove (no-spam) |
PIC 18F452 microcontroller withAnalog In/Out, Digital In/Out, Serial In/Out
|
System Software (continued) |
A PIC project with Light Level Detection, SIRC and |
' ==========i/o pins========= |
Init, MainLoop |