Here is some code to do most of what your pic was originally programmed to do.
I think it will run on the demo, if it is too long then just comment out the last couple of statements in the main.
Code:
@ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF
'DEFINE OSC 4
'DEFINE ADC_CLOCK 1
'OSCCAL=%10000000
'GPIO = 0 ' set all outputs low
TRISIO = %00000001 'Set GPIO.0 to input
cmcon = 7 'Disable analog comparators
ANSEL = 1
'PCON = %00000011 ' Bit 0 BOD 0=on 1=off bit 1 POR 0=on 1=off
ADCON0 =%00000011 ' SET CHANNEL 0 RT JUSTIFIED VREF - VDD
' BIT 7 1 LT JUSTIFY 0 RT JUSTIFY
' BIT 6 1 = VREF 0 = VDD
' BIT 5:4 UNIMPLEMENTED
' BIT 3:2 00 CH 0
' 01 CH 1
' 10 CH 2
' 11 CH 3
DELAY VAR WORD
main:
ADCIN 0,DELAY
DELAY = (DELAY * 4)
TRISIO = %11111001
GPIO = %00000010 'LED 7 ON
PAUSE DELAY
GPIO = %00000100 'LED 6 ON
PAUSE DELAY
TRISIO = %11011011
GPIO = %00000100 'LED 5 ON
PAUSE DELAY
GPIO = %00100000 'LED4 ON
PAUSE DELAY
ADCIN 0,DELAY ' RECHECK A/D AND RECALIBRATE
DELAY = (DELAY * 4)
TRISIO = %11101011
GPIO = %00000100 ' led 3 ON
PAUSE DELAY
GPIO = %00010000 'led 2 ON
PAUSE DELAY
TRISIO = %11001111
GPIO = %00100000
PAUSE DELAY
GPIO = %00010000
'PAUSE DELAY
goto main
After you play with these you may be ready to order PBP. Then you can UnComment the rest of this code.
Last edited by Archangel; - 22nd February 2010 at 05:15.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Bookmarks