hi i am trying to use a pic to sense for alcohol content, i am going to be using a pot as the sensor as we cannot get hold of one. therefore i want to mimic the circuit. basically all i want it to do is light either and led stating "dont drive" or "ok to drive". So i was going to have two inputs there for if the voltage input to one pin is higher than the other(reference) i want the led to come one.
The problem is i am unsure how to read inputs into a pic, i have made the code below, i have not tested it yet but before i do i wanted to make sure i have not missed anything out.
P.S the delay is put in there for the heater in the sensor (not being used in this case)
Finally i have never wired up a PIC using the internal occilator. do i just need to add 5V and 0V anything else i need to add?
'****************************************************************
'* Name : groupproject.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2005 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 23/01/2005 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************************************
xtal=4 '4mhz
symbol LED = Portb.0 'Delay on led
symbol LED2 = Portb.1 'output led1
symbol LED3 = Portb.2 'output led2
SYMBOL PIN1 = PORTB.3 'inputs
SYMBOL PIN2 = PORTB.4 'inputs
INPUT PORTB.3 'defining input
INPUT PORTB.4 'defining input
Delayms 40000 'sensor warm up time 40secs
High LED 'sensor warm led on after 40secs
Start: 'start
Low LED2 'led off
Low LED3 'led off
IF PIN1 > PIN2 THEN High LED2 'if pin1 is less than pin2 make led come on
IF PIN2 > Pin1 THEN High LED3 'if pin2 is less than pin1 make led come on
Goto Start 'go back to start
The problem is i am unsure how to read inputs into a pic, i have made the code below, i have not tested it yet but before i do i wanted to make sure i have not missed anything out.
P.S the delay is put in there for the heater in the sensor (not being used in this case)
Finally i have never wired up a PIC using the internal occilator. do i just need to add 5V and 0V anything else i need to add?
'****************************************************************
'* Name : groupproject.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2005 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 23/01/2005 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************************************
xtal=4 '4mhz
symbol LED = Portb.0 'Delay on led
symbol LED2 = Portb.1 'output led1
symbol LED3 = Portb.2 'output led2
SYMBOL PIN1 = PORTB.3 'inputs
SYMBOL PIN2 = PORTB.4 'inputs
INPUT PORTB.3 'defining input
INPUT PORTB.4 'defining input
Delayms 40000 'sensor warm up time 40secs
High LED 'sensor warm led on after 40secs
Start: 'start
Low LED2 'led off
Low LED3 'led off
IF PIN1 > PIN2 THEN High LED2 'if pin1 is less than pin2 make led come on
IF PIN2 > Pin1 THEN High LED3 'if pin2 is less than pin1 make led come on
Goto Start 'go back to start