Hi Naga. I did something like this before. I edited the code & schematic to show only the relevent info. The only thing different is if you press the bottom 2 switches at the same time, it will do a 5th function.
ANSEL = 0 'all inputs digital ADC command converts to analog
CMCON = 7 'comparators off
DEFINE OSCCAL_1K 1 ' Set OSCCAL for 1K device
@ device pic12F675, INTRC_OSC_NOCLKOUT, wdt_on, BOD_ON, pwrt_on, mclr_off, protect_on
BUT VAR BYTE 'MESSAGE BUTTONS VARIABLE
BUT2 VAR BYTE 'VARIABLE TO COMPARE BUT READINGS TO PREVENT WRONG ADC READINGS
Pause 500 'SETTLE DOWN
START:
NAP 0 'REDUCE STANDBY CURRENT
ADCIN 3,BUT
IF BUT < 100 Then TABLE 'BUTTON PUSHED
GoTo START
TABLE:
ADCIN 3,BUT
Pause 100
ADCIN 3,BUT2
IF BUT <> BUT2 Then TABLE 'RE-READ THE ADC
IF BUT < 91 AND BUT > 71 Then (DO 1ST THING)
IF BUT < 50 AND BUT > 40 Then (DO 2ND THING)
IF BUT < 15 AND BUT > 8 Then (DO 3RD THING)
IF BUT < 8 AND BUT > 4 Then (DO 4TH THING)
IF BUT < 5 AND BUT > 2 Then (DO 5TH THING)
GOTO START
@ Peterdeco1,Thank you very much .. Very nice..Working perfectly.. Thanks to all of you..
Other problem is..
When using MeLabs default (PM) Assembler compiles OK:
@ device pic12F675, INTRC_OSC_NOCLKOUT, wdt_on, BOD_ON, pwrt_on, mclr_off, protect_on
When using Microchip's (MPASM) Assembler:
@ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _BODEN_ON
3 errors,image attached..
Last edited by naga; - 18th August 2009 at 08:45.
1 error and two warnings.
Not sure about the warnings but they are just warnings.
The error looks like the Inc file has not been commented out.
http://www.picbasic.co.uk/forum/showthread.php?t=543
Dave
Always wear safety glasses while programming.
Bookmarks