I hope someone can help me with this
I have two ir (transmiter-receiver) and I need to know when it is someting that interrupts the signal. I mean someting is between them …
the hardware I have is this one
FROM THE SAME PAGE
This is a very simple set up: The IRL 80 A IR sender (glowing blue at bottom right) has its long lead connected to arduino 5, the short lead to ground. Behind it is the LPT 80 A IR receiver (hard to see because clear) with its long lead connected to 5V and short lead connected to both A1 on Arduino and to a 10 K resistor that goes to ground.
I need very small sensors that is why I chose those for this.
If nothing is between the sensors I got from 1013 to 1017 in the A0 port (analog reading)
if the sensors are covered I got from 1016 to 1020 …
The problem is I got 1016 and 1017 in both cases. I expected to get diferent numbers so I can see a diference to know if the sensors are covered or not.
The method I have to get those values is the next one.
Any help will be very good for me since I do not know much about this.
int getSensorsValues( char vl_To_Return ) {
int minValue ; int maxValue ; unsigned long time ; int irRead ;
unsigned long st ; unsigned long sample ;
minValue = 32767 ;
maxValue = -32768 ;
sample = (millis() + 100) ;
time = (millis() + 10000) ;
st = (millis() + 2000) ;
//digitalWrite( _Receptor_PWM, HIGH ) ;
//digitalWrite( _Trasmisor_PWM, HIGH ) ;
do {
irRead = analogRead( _Receptor_ANLG ) ;
//Serial.println( irRead ) ;
if ( millis() > sample ) {
if ( irRead < minValue ) {
minValue = irRead ;
}
if ( irRead > maxValue ) {
maxValue = irRead ;
}
}
if ( millis() >= (st + 2000) ) {
lcd.clear() ;
lcd.setCursor ( 0, 0 ); // columna fila
lcd.print( "Mn: " ) ;
lcd.print( minValue ) ;
lcd.setCursor ( 0, 1 ) ; // columna fila
lcd.print( "Mx: " ) ;
lcd.print( maxValue ) ;
st = millis() ;
}
} while (millis() <= time) ;
//digitalWrite( _Receptor_PWM, LOW ) ;
//digitalWrite( _Trasmisor_PWM, LOW ) ;
lcd.clear() ;
lcd.setCursor ( 0, 0 ); // columna fila
lcd.print( "Mn: " ) ;
lcd.print( minValue ) ;
lcd.setCursor ( 0, 1 ) ; // columna fila
lcd.print( "Mx: " ) ;
lcd.print( maxValue ) ;
if ( vl_To_Return == 'X' ) { // Mayor valor
return maxValue ;
} else if ( vl_To_Return == 'N' ) { // Menor valor
return minValue ;
}
}