ankit-max
Junior Member level 1
- Joined
- Dec 20, 2012
- Messages
- 17
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,402
I have a PIC 16F72 Micro-controller. I have used VDD as PIC 5v and gnd (0 V) from the pic. The port pin A.0 is used as an analog pin to give analog voltage using a potentiometer. Circuit diagram is shown as below:
Using Proton as a compiler. Setting for ADC:
Declare Adin_Res 8
Declare Adin_Tad 32_FOSC
Declare Adin_Stime 50
ADCON1 = %00000010
TRISA = %00000111
OUTPUT PORTB.7 'LED connected
Low PORTB.7
I have connected a led to PORTB.7 which switches to ON state when voltage at PORTA.0 is greater than 3.5V otherwise stays OFF. The problem I am getting is when I start the PIC led blinks on and off now when I change the voltage through dimmer, it gets OFF and when I increase the voltage through dimmer, it still stays OFF even when the analog voltage to the pin A.0 is greater than 3.5v. For sometime I thought it may be the ground problem with ADC. But, I am kind of perplexed as to clear out what is going wrong. Please any help would be appreciated.
Thanks.
Using Proton as a compiler. Setting for ADC:
Declare Adin_Res 8
Declare Adin_Tad 32_FOSC
Declare Adin_Stime 50
ADCON1 = %00000010
TRISA = %00000111
OUTPUT PORTB.7 'LED connected
Low PORTB.7
I have connected a led to PORTB.7 which switches to ON state when voltage at PORTA.0 is greater than 3.5V otherwise stays OFF. The problem I am getting is when I start the PIC led blinks on and off now when I change the voltage through dimmer, it gets OFF and when I increase the voltage through dimmer, it still stays OFF even when the analog voltage to the pin A.0 is greater than 3.5v. For sometime I thought it may be the ground problem with ADC. But, I am kind of perplexed as to clear out what is going wrong. Please any help would be appreciated.
Code:
Device 16F72
Xtal 4
'Settings for ADC
Declare Adin_Res 8
Declare Adin_Tad 32_FOSC
Declare Adin_Stime 50
Output PORTB.7 'Led connected
Low PORTB.7
Dim x As Byte 'to store digital value
GoTo start
analog:
x=ADIn 0
DelayMS 10
Return
start:
x=0
lp:
GoSub analog
If x > 180 Then
High PORTB.7
ElseIf x < 180 Then
Low PORTB.7
EndIf
GoTo lp
Thanks.