hi everybody
can you help me, I'm making a project using e18-d80nk x3, but when one of them is detecting an object, the other sensor can't detect it, can you give me some input.
this is my program...
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define counter_pin 2 // Set Pin
LiquidCrystal_I2C lcd(0x27,16,2); // Alamat LCD
bool item_detected = false;
int item_counter = 0;
void setup()
{
Serial.begin(9600);
pinMode( counter_pin , INPUT);
lcd.begin(); // Start LCD
// Print a message to the LCD.
lcd.setCursor(0,0); // Baris Atas
lcd.print("PERSIAPAN");
lcd.setCursor(2,1); // Baris Bawah
lcd.print("PERHITUNGAN:)");
delay(3000);
}
// Sub Counter Pembaharuan Jumlah
void loop()
{
int val = digitalRead( counter_pin );
if( (item_detected == false) && ( val == 0 )){
item_detected = true;
item_counter++;
updateCounter();
}
else if( (item_detected == true) && ( val == 1 )){
item_detected = false;
}
}
// Katerangan Jumlah Hitung Pada Antarmuka LCD
void updateCounter(){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("JUMLAH BENIH");
lcd.setCursor(0,1);
lcd.print(item_counter);
}