Go Down

Topic: Bidirectional Visit Counter  (Read 868 times) previous topic - next topic

akshaygorde

Hi....
        I have a problem to the code of the bidirectional visit counter. I have a code but the code shows in LCD only one IR sensor but I need two sensor .
Code: [Select]
#include <Wire.h>
#include <time.h>
#include <LiquidCrystal.h>
#define sensor x = A0
#define colx 8

int sensor;
LiquidCrystal lcd(0,1,8,9,10,11);

void setup()
{
  pinMode(sensor, INPUT);
  lcd.begin(16,2);
  lcd.setCursor(0,0);
  lcd.print("Count :");
  lcd.setCursor(0,1);
  lcd.print("Message :");
}

int v;
int state;
int laststate = LOW;

void loop()
{
  int senread = digitalRead(sensor);
  char count[10];
 
  int state = senread;
 
  if(state == HIGH && laststate == LOW)
  {
    v = v+1;
    delay(1000);
    lcd.setCursor(colx,0);
    sprintf(count,"%d", v);
    lcd.print(count);
    lcd.setCursor(colx,1);
    lcd.print("VEHICLE");
  }
  if (v > 10)
  {
    v=0;
    delay(1000);
    lcd.setCursor(colx,0);
    sprintf(count,"%d", v);
    lcd.print(count);
    lcd.setCursor(colx,1);
    lcd.print("MAX VEHICLE");
  } 
  delay(1);
  laststate = state;
//  return(0);
}

Go Up