I'm trying to write a code that will print a readout of how many customers pass through a door in a minute, I have it mostly down I think but i'm getting an error that says "expected primary expression before '>' token. I'm very new to this and don't have much experience in coding so go easy on me. I'll paste my code below.
int ledPin = 13; // LED connected to digital pin 13
int photoPin = 2; //
int val = 0;
int valold = 0;
int start;
unsigned int count = 0;
void setup() // run once, when the sketch starts
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
pinMode(photoPin, INPUT);
valold = digitalRead(photoPin);
Serial.begin(9600);
}
void loop() // run over and over again
{
start = millis(); // take the start time
count = 0; // reset couter
// do the following loop for 60000ms = 1min
while (millis()-start < 60000)
{
// check for overflow of millis()
if (start > millis()
) {
start = millis();
count = 0;
}
val = digitalRead(photoPin);
if (val==LOW)
{
digitalWrite(ledPin, LOW);
}
else
{
digitalWrite(ledPin, HIGH);
if (val <> valold) {
count ++;
valold = val;
}
}
}
// 1 minute over. print conts
Serial.print("Customers per minute: ");
Serial.println(count,DEC);
}
It would have helped if you did read How to use the forum as suggested. That would have told you to post to use code tags AND to post the complete error code. Because, surprise! It does contain more info Like, where the error is.
Code works now but i'm just getting a printout that says " customers per minute : 0 " doesn't seem to count up at all even though i'm waiving in front of the sensor and the led is going on and off.
int ledPin = 13; // LED connected to digital pin 13
int photoPin = 2; //
int val = 0;
int valold = 0;
int start;
unsigned int count = 0;
void setup() // run once, when the sketch starts
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
pinMode(photoPin, INPUT);
valold = digitalRead(photoPin);
Serial.begin(9600);
}
void loop() // run over and over again
{
start = millis(); // take the start time
count = 0; // reset couter
// do the following loop for 60000ms = 1min
while (millis()-start < 60000)
{
// check for overflow of millis()
if (start > millis()
) {
start = millis();
count = 0;
}
val = digitalRead(photoPin);
if (val==LOW)
{
digitalWrite(ledPin, LOW);
}
else
{
digitalWrite(ledPin, HIGH);
if (val != valold) {
count ++;
valold = val;
}
}
}
// 1 minute over. print conts
Serial.print("Customers per minute: ");
Serial.println(count,DEC);
}
Here is my updated code, Code seems to work now but i'm just getting a printout that says " customers per minute : 0 " doesn't seem to count up at all even though i'm waiving in front of the sensor and the led is going on and off.