'How to read two different IR sensor data in Arduino and Send that data to web application through node.js
so, when I run the node.js server it will getting the sensor data but in the web both are working but, when i cover one sensor both 'slots' display as not available.
Node js code
Index.html
Arduino code
String notav = "Not Avaiable";
void setup() {
Serial.begin(9600);
pinMode(4,INPUT);
pinMode(7,INPUT);
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);
}
int i = 1;
void loop() {
if(digitalRead(4)== HIGH){
digitalWrite(11,HIGH);
digitalWrite(12,LOW);
Serial.println(av);
}else{
digitalWrite(11,LOW);
digitalWrite(12,HIGH);
Serial.println(notav);
delay(5000);
}
// second sensor
if(digitalRead(7)== HIGH){
digitalWrite(11,HIGH);
digitalWrite(12,LOW);
Serial.println(av);
}else{
digitalWrite(11,LOW);
digitalWrite(12,HIGH);
Serial.println(notav);
delay(5000);
}
}```
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
