Can Arduino Read This?


Function Table

As the image attached above, is there any method other than IF statement can read the table in the image?

I’m beginner in programming, was wonder any good method to let the arduino read this.

Each column inside the thicken box are the same single action.

//Edit: Thanks Robin2, I had used imgur as host but it never show my image even I had used . :sweat_smile:

is the table in a file of a known format? if so they could be libraries which can read it

winterpie: As the image attached above,

Please make your image visible in your Post. See this Simple Image Posting Guide

...R

Yes, you could put the data into an array and just read it back.

byte goingIn1[] = {
1,0,0, 
1,1,0, 
1,1,1, 
};

byte goingIn2[] = {
1,0,0,
2,1,0,
1,2,1,
};
etc.

I don't know what to make of the True/False part where a 1 for example can true or false. You could also do it as one larger multidimensional array vs having 18 arrays.

Not exactly clear what you are asking. Do you want the arduino to read the file the function table is stored in, and if so what do you intend to do with the data once it has been read? Or do you want to use the arduino to input some type of data, and then see which function table matches the data?

CrossRoads: I don't know what to make of the True/False part where a 1 for example can true or false.

Typically, in C++, false is defined as 0 (zero) and true is not false.

OP’s chart, you can see the use of 0,1,2,3 and True, False.

(Oooh, that was cool! I attached the Image, and it autoposted the Image without the manual copy/pasting that we had been doing!)

horace: is the table in a file of a known format? if so they could be libraries which can read it

The table is simulating for when the store value had meet any kind of these arrangement, it will know what's is going on and do the things next.

Robin2: Please make your image visible in your Post. See this Simple Image Posting Guide

This solved my problem for uploading image, very appreciate! :D

CrossRoads: Yes, you could put the data into an array and just read it back.

byte goingIn1[] = { 1,0,0,

Can I made a array with the boolean too? I want to use the data like [1,0,0]+[true,false,false] together.

david_2018: Not exactly clear what you are asking. Do you want the arduino to read the file the function table is stored in, and if so what do you intend to do with the data once it has been read? Or do you want to use the arduino to input some type of data, and then see which function table matches the data?

Yes, i would like to input the data into arduino and then see which function table meets the scenario, then proceed with the next operation.

Yes, i would like to input the data into arduino and then see which function table meets the scenario, then proceed with the next operation.

How will the data be input?

“I want to use the data like [1,0,0]+[true,false,false] together.”
1 and 0 are equivalent to true and false.

What would 2 and 3 represent in that?

Anything not 0 is equal to true generally. Is that what you after?

cattledog: How will the data be input?

I think this may be related to the OP's other post https://forum.arduino.cc/index.php?topic=704935.0 , I'm having a lot of difficulty trying to understand the explanations of what the code is suppose to do.

david_2018:
I think this may be related to the OP’s other post https://forum.arduino.cc/index.php?topic=704935.0 , I’m having a lot of difficulty trying to understand the explanations of what the code is suppose to do.

Exactly, that’s why I’m asking in another way of it, to get as many result as possible.

There are 3 sensors. If people passing(being scanned, and leave) by S1, then S1 will +1. But if the person stand still, the sensor will become TRUE, will still +1 no matter where the people leave in either direction.

-----------> Enter
<----------- Exit

GOING IN I
S1 S2 S3
1 0 0 //1 People coming in
True False False

S1 S2 S3
1 1 0 //He is continuing moving
False True False

S1 S2 S3
1 1 1 //He is entering the building
False False True

GOING IN & GETTING BLOCK I
S1 S2 S3
1 0 0 //1 People coming in
True False False

S1 S2 S3
1 1 1 //He is continuing moving, but another person wanna go out
False True True

S1 S2 S3
1 1 2 //He is entering the building after another person give the way
False False True

GOING IN & TURN BACK I
S1 S2 S3
1 0 0 //1 People coming in
True False False

S1 S2 S3
1 1 0 //He’s seems like forget something
False True False

S1 S2 S3
2 1 0 //He’s turn back and go somewhere else
True False False

S1 or S3 may get higher value if many people refuse to go in at S1, or refuse to go out at S3.

The value in S1 or S3 will be disappear after 5 second if not being used for peopleCounted.

But if people coming in a row, it will also produce the value more than 2 or 3.
GOING IN III
S1 S2 S3
1 0 0 //1 People coming in
True False False

S1 S2 S3
2 1 0 //He is continuing moving, another people following up
True True False

S1 S2 S3
3 2 1 //He is entering the building, the second people still following, the third people following too
True True True

At the point when a person is successfully enter a building, peopleCounted++, S1–, S2–.

It also applied in the reverse way when someone leaving, peopleCounted–, S3–, S2–.

The whole process may not happened instantly or 100% in this pattern, may slow a bit or faster a bit.

I had used IF statement to include another IF statement, and on, and on, and on.

It seems like the IF statement is doing the thing I want which is IF this, THEN this, THEN that.

But to get the final result, which is peopleCounted++ or –, it might not works unless the situation is 100% correct and instantly.

Will the trigged frequency of Ultrasonic Sensor affect the final result? Or actually I’m using a wrong way to make things done?

I'm using a wrong way to make things done?

I'm not really certain what you are doing and why, but most of the Arduino bidirectional visitor counters use only one or two sensors. There is plenty to be found online. Another search term along with "arduino bidirectional visitor counter" is "arduino count people in and out of a room".

cattledog: "arduino bidirectional visitor counter" is "arduino count people in and out of a room".

You make me start to reconsider using back 2 sensors as bidirectional sensor.

The reason that I used 3 sensor instead of 2 is because to get ride of the issue of when the people turn back suddenly in the second sensor.

Do you really care about people who hesitate or turn around?

Does the project actually require you to count partial entry and partial exit beyond the point of tripping one sensor and not the other?

Where is the placement of the sensors?

In my thinking, if people linger under a second sensor after tripping a first and then turn around, they actually don't enter or leave the room. The count of people inside (the stated objective of the project) doesn't change.

The issue of the lingering may be best solved with time outs for complete off/on/off transitions for each of the sensors.

As I said, this is a well discussed topic, and I'm sure the advanced design parameters are available for research.

Have you did observations of the people traffic to see how many people, per day, hesitate and turn back?

If 1000 people pass by and 1 hesitates and 1 tuns back, would that be an acceptable error vs the expense of trying to make it work for the condition?

Idahowalker: Have you did observations of the people traffic to see how many people, per day, hesitate and turn back?

If 1000 people pass by and 1 hesitates and 1 tuns back, would that be an acceptable error vs the expense of trying to make it work for the condition?

!!!!!!

Thanks Idahowalker!!! Now I know how to write my project report. :D

Another question about your project. How do you account for people carrying a brief case or a bag of groceries, or two children holding a parents hand?

Paul

Paul_KD7HB: Another question about your project. How do you account for people carrying a brief case or a bag of groceries, or two children holding a parents hand?

Paul

Brief case which lower than 145cm will not be counted, so do the child.

But if still wanted to account the children, I think I may add another row of sensor just for children, which sensed everything that lower than 145cm but higher than... let's say about 60cm(which higher than dogs and cats I think.)

If brief case get sensed when go in, it will get sensed too if go out, so no problem I think.