Page 1 of 1
Read 2 Sensors at the same time
Posted: Mon May 11, 2015 3:12 pm
by JDR04
I've done a flowchart with the objective of reading two LDR's at the same time.(Represented by LIGHTLEVEL1 and LIGHTLEVEL2)
I can get the light to flash on and off by manipulating LIGHTLEVEL1 but LIGHTLEVEL2 seems to have no effect.
The idea is both sensors need to detect two lights switching off at exactly the same time. If only one light switches off then the LED stays off.
Any help on this one will be appreciated. John
Re: Read 2 Sensors at the same time
Posted: Mon May 11, 2015 4:22 pm
by Benj
Hello John,
Are your components marked correctly? Could this be the cause of the problems your seeing.
Pot ADC(3) is marked LIGHTLEVEL1 and connected to pin AN0, however in your flow chart LIGHTLEVEL1 reads component ADC(0)
Pot ADC(0) is marked THRESHOLD1 and connected to pin AN2, however in your flow chart THRESHOLD1 reads component ADC(3)
LIGHTLEVEL2 references seems correct.
You shouldn't need the delays in between ADC reads if you want to sample multiple channels one after another at high speed.
If you want to check both ADC readings are below the threshold then you can use this in your decision icon.
Code: Select all
(LIGHTLEVEL1 < THRESHOLD1) && (LIGHTLEVEL2 < THRESHOLD1)
Re: Read 2 Sensors at the same time
Posted: Mon May 11, 2015 4:37 pm
by medelec35
Hi John, in addition to Ben's comments,
If you press single step (F8) then within Variable window add all the variables by right click & select Add variable:
You will see that the values are wrong when you turn pots confirming what Ben is stating.
During simulation, adding variables to watch is useful practice.