Hello, my following code is not working for some reason. Can someone help please.
On my computer screen I am getting Time=0, Ambient=0. Time Pin is connected to +5V with a 4.7k, I have not attached a POT yet, even though when I did, the voltage on the pin was around 2.5V, but the reading was still 0.
LDR voltage is going to Ldr pin. LDR is connected in voltage divider fashion with voltage going to PIC using a 4.7k. Again I tried to change the voltage as well on this pin but the reading stays as 0.
Thanks in advance.
Code:;-----------------PIC16F676---------------------------Include "modedefs.bas" DEFINE OSC 4 ' OSCCON defaults to 4MHz on reset ;DEFINE OSCCAL_1K 1 DEFINE ADC_BITS 10 DEFINE ADC_CLOCK 3 DEFINE ADC_SAMPLEUS 50 ;-------------CONFIGURATION FUSES SET HERE------------------------- @ __Config _XT_OSC & _WDT_OFF & _PWRTE_ON & _MCLRE_OFF & _BODEN & _CP & _CPD '---------------------------------------- DEFINE DEBUG_REG PORTC DEFINE DEBUG_BIT 5 DEFINE DEBUG_BAUD 2400 DEFINE DEBUG_MODE 0 '-------Analog Input-------------- Poten Var PortA.1 Ldr Var PortC.3 '-------------------------------------- Time Var Word Time1 Var Word Counter Var Byte Ambient Var Word Ambient1 Var Word B0 Var Word ;------REGISTERS SET -------- PORTA=0 PORTC=0 TRISA = 0010 TRISC = 1110 OPTION_REG = 128 PORTA=0 PORTC=0 CMCON=7 ANSEL=000010 ADCON1=110000 ADCON0=000000 '--------------------------------------- Pause 3000 GoSub LoadTime Time1=Time GoSub LoadLight Counter=0 Main: ; my rest of the code Goto Main LoadTime: ADCIN Poten,Time : Pause 10 ; Time=(Time/4) DEBUG "TIME=",DEC Time,10 Return LoadLight: ADCIN Ldr,Ambient : Pause 10 DEBUG "AMBIENT=",DEC AMBIENT,10 While Setswitch=1 : Pause 330 : wend Return


,



Bookmarks