Deleted.

Deleted.

What is the relevance of the traffic flow sensors ?
Have you been told to weight the length of the "green" period to correspond with the amount of traffic ?

Deleted.

cromarko:
My Arduino works but I can't make the logic work. Can you guys please help me with Q2 of this assignment? I did make a truth table but the teacher says it is wrong and I have no where to get extra support. Thank you! If you are generous, can you help me with other questions too?

Oh yeah.....sure, we'll do the assignment for you.

Actually...... if the teacher says it's wrong, then ask the teacher to point you or guide you in the right direction. Otherwise, you should show your attempt here to the best of your ability, and then somebody could have a look at it if you attempted to answer it to the best of your ability.

D B A C EW_Green NS_Green
1 1 X X 1 0
1 0 0 0 1 0
0 1 0 0 1 0
0 0 1 1 0 1
0 0 0 1 0 1
0 0 1 0 0 1
0 0 0 0 1 0

I don't know if what I had will help or whether it is correct. But use it as a guide.

Oh. Sorry. For some reason I missed the detail on your original post which describes how the sensors are to be interpreted.

You've been given a wiring diagram to follow ?

Have you got this far ?

  1. The east - west (E - W) traffic light will be green whenever both lanes D and B are occupied.
  2. The E - W light will be green whenever either D or B is occupied but lanes A and C are not both occupied.

It would look like this in a truth table:

sensorA  sensorB sensorC sensorD   LightEW  LightNS
   X       HIGH    X       HIGH     GREEN    -          (from statement 1)
 LOW       HIGH   LOW      HIGH     GREEN    -          (from statement 2)
 HIGH      HIGH   LOW      HIGH     GREEN    -          (from statement 2)
 LOW       HIGH   HIGH     HIGH     GREEN    -          (from statement 2)

etc.
X = don't care

Then you have to complete and refine it.

Edit: crossed with your post.

  • Assign the value 1 to lane A, 2 to lane B, 4 to lane C and 8 to lane D
  • Read all the detectors.
  • Set the variable detectedTotal = 0
  • If a detector is HIGH add the appropriate value to detectedTotal.

Then you will have a unique value in detectedTotal for every combination and you can test that value with a series of IFs or maybe SWITCH CASE and act on it.

...R

Deleted.

If you have A B C D as 0 0 1 1 .... then car C would slam into car D if both EW and NS lights are green. So you have NS being green....or 1....which is ok. But you also need to set EW to 0.....instead of leaving it blank.

My attempt looks like this. But it is a long time since I did anything similar :

tt.JPG

re-read rule #4 and review your table.

Deleted.

Still not complete. You need to fill in all of the NS column and all of the EW column. Your teacher would significantly mark you down for leaving things blank.....and failing to do what's obvious.....as in leaving things out when we clearly know we need to fill in the blanks.

And to help with the remainder of the assignment, http://www.32x8.com/

cromarko:

This is what I am looking for. My truth table is wrong, I followed all the instructions but the parts that are in blue for N-S are actually not right. I have no problems with the Arduino but since my logic isn't right in the Sketch, I am at possibility of failing the assignment.

Can someone help me with the truth table?

This is not showing that you attempted the question to the best of your ability. Best of your ability means writing down your thinking --- your reasoning for putting those values into those areas that you did. This means..... systematically and methodically writing each 'rule' (eg. label or number each rule from the assignment), then showing how or why you chose each row of your truth table. Simply plonking down a bunch of values into the truth table without conveying reasoning/logic is a poor approach.

6v6gt is showing you at a systematic/methodical approach.

Not that it’s germane to you getting it to work according to the rules, but Rule#1 is insane. The whole point of a traffic light is to let the cars in the side road out every now and then, even though the main road is busy; indeed especially when the main road is busy. That rule says to keep EW flowing as long as there are cars on both B & D, which means that the heavier the EW traffic the worse it gets for the guys on NS. They’ll sit there for hours in the morning rush…

Get yourself a bonus point by adding a timer in there, along the lines of:

  • The N - S light will go green when either A or C is occupied AND N-S has been red for seconds.

Hi,
Is this the exact wording of the requirements of your project, or your interpretation of them?

Problem - Figure below shows the intersection of a highway with a local street.. Vehicle detection sensors are placed along lanes B and D ( highway ) and lanes A and C ( Street ). These sensor outputs are LOW (0) when no car is present and HIGH (1) when a car is present. The intersection traffic light is to be controlled according to the following logic:

  • The east - west (E - W) traffic light will be green whenever both lanes D and B are occupied.
  • The E - W light will be green whenever either D or B is occupied but lanes A and C are not both occupied.
  • The north - south (N - S) light will be green whenever both lanes A and C are occupied but D and B are not both occupied.
  • The N - S light will also be green when either A or C is occupied while D and B are both vacant.
  • The E - W light will be green when no vehicles are present.

Can you post a picture of your assignment sheet with the required actions needed from your project?

Thanks.. Tom... :slight_smile:

ShetLand:
Not that it's germane to you getting it to work according to the rules, but Rule#1 is insane. The whole point of a traffic light is to let the cars in the side road out every now and then, even though the main road is busy; indeed especially when the main road is busy.

I was thinking the assignment was a crawl before walking.
if you cannot make this part work, the complications associated with good traffic control would be overwhelming.
Also, the assignment is clear enough that getting it done will reveal to the professor what needs to be addressed and what was missed in the lectures.
it was clear in his truth table that he did not follow the rules set forth.
since he was unable to complete this task, adding multiple layers of complexity would not be good teaching.
I would expect that the professor has those layers as phase-II and phase-III so that by the end of the class, the professor walked the students along the path and they all came out with true knowledge of the work.

cromarko:

This is what I am looking for. My truth table is wrong, I followed all the instructions but the parts that are in blue for N-S are actually not right. I have no problems with the Arduino but since my logic isn't right in the Sketch, I am at possibility of failing the assignment.

Can someone help me with the truth table?

re-read rule #3 and rule #4 and then look at line 4 and figure how you violated the rules.

good teaching makes you come to a realization.
if we give you the answers, we actually hurt your learning.

I thought also that the exercise was quite well structured because the student could create a system to test his work and was able to conclude on his own by pressing buttons and watching LEDs that the truth table he had put together failed.

Of course, like a lot of these school exercises, there is an attempt to relate them to a real world situation so it does not appear too abstract to the student. However, a lot of the complexity of the real world situation has to be stripped out to make it a manageable problem. That is OK because, presumably, this is an exercise in logic and not in traffic management. However, such simplifications, when completely unrealistic, can cause confusion.