'**************************************************************** 'shade '**************************************************************** 'Declare everything define OSC 4 DEFINE ADC_BITS 10 ' Set number of bits in result DEFINE ADC_CLOCK 3 ' Set clock source (3=rc) DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS ADCvar VAR WORD ' Create variable to store result TRISA = %11111111 ' Set PORTA to all input this is the pot ADCON1 = %10000010 ' Set PORTA analog and right justify result TRISB = %00000000 ' Set PORTB to all Output ELpanels 1 - 8 OUTPUT portd.3 ' ELpanel 9 OUTPUT portd.2 ' ELpanel 10 output portd.1 ' blinky led strip1 VAR portb.7 strip2 VAR portb.6 strip3 VAR portb.5 strip4 VAR portb.4 strip5 VAR portb.3 strip6 VAR portb.2 strip7 VAR portb.1 strip8 VAR portb.0 strip9 VAR portd.3 strip10 VAR portd.2 debugLED var portd.1 'Here comes blinky high debugLED pause 250 low debugLED pause 250 high debugLED pause 250 low debugLED pause 250 'The Action main: ADCIN 0, ADCvar ' Read channel 0 to adval serout2 PORTC.6, 16468, [DEC ADCvar, 13, 10] ' print it to serial out, ' with linefeed and carriage return (10, 13) ' switch based on pot values of 1 - 1000 if (adcvar <= 100) then high strip1 else Low strip1 endif if (adcvar <= 200) then high strip2 else Low strip2 endif if (adcvar <= 300) then high strip3 else Low strip3 endif if (adcvar <= 400) then high strip4 else Low strip4 endif if (adcvar <= 500) then high strip5 else Low strip5 endif if (adcvar <= 600) then high strip6 else Low strip6 endif if (adcvar <= 700) then high strip7 else Low strip7 endif if (adcvar <= 800) then high strip8 else Low strip8 endif if (adcvar <= 900) then high strip9 else Low strip9 endif if (adcvar <= 1000) then high strip10 else Low strip10 endif GoTo main ' Do it forever