I need a program to print on the screen the pulse count of 3 occupancy sensors.
I use Arduino 2009 and 16x2 LCD SHIELD.
I did put the code below is not working properly, what could it be?
// include the library code:
#include <LiquidCrystal.h>
int conta1 = 0;
int conta2 = 0;
int conta3 = 0;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print(conta1);
lcd.print(conta2);
lcd.print(conta3);
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
if (digitalRead(1)==HIGH)
{
conta1++;
}
if (digitalRead(2)==HIGH)
{
conta2++;
}
if (digitalRead(3)==HIGH)
{
conta3++;
}
}
I made some modifications, but the error still remains. I think the digital port 0 is varying between 0 and 1. because with port 0 disconnected the serial monitor is counting infinitely