Hey guys I'm using a TEPT5700 as a break beam sensor.
Sensor circuit:
Blue wire == 5v, grey wire == PIN 2, purple wire == GND.
The code I have is for use with a PNP sensor but I'm using an NPN sensor. The sensor closes when light is detected from my laser and then closes my relay. But what I would like is for the sensor to close when the laser beam is broke.
How do I ajust the code accordingly for this situation.
I'm still learning to code and i work well with examples. Sorry again if I'm not coming across clearly with my explanation.
Thankyou kindly.
const int ledPin1 = 12;
const int ledPin2 = 13;
const int sensorPin1 = 2;
const int sensorPin2 = 3;
const int TIMEOUT = 3000; // milliseconds
// Setup runs once, at start
// Input and Output pins are set
void setup(){
pinMode(sensorPin1, INPUT);
pinMode(sensorPin2, INPUT);
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
}
// Called repeatedly
void loop() {
// Get the Sensor status
int status1 = digitalRead(sensorPin1);
int status2 = digitalRead(sensorPin2);
// Set the output LED to match the sensor
digitalWrite(ledPin1, status1);
digitalWrite(ledPin2, status2);
if (status1 == HIGH || status2 == HIGH) {
// A sensor was tripped, show the results until timeout
delay(TIMEOUT); // Wait for timeout
}
}

