Logic circuit coding trouble

Dear Arduino people,

I need help with a project I'm on for school. I've tried to finish the assignment without any help but I can't seem to finish it as I'm getting stuck. The project is due in a few days; I hope you're able to help me.
Note that I have no trouble connecting the actual LEDs and buttons. I am using an Arduino Uno. The only issue I have is coding.

Assignment:

"Write a program that displays the output of the following logic circuit"
So what I did first is make a truth scheme to see when the output is true:


Note: I made a truth scheme for the logic circuit to display outputs (highlighted in green)

  • Use four LEDs as an input (representing i1, i2, i3, i4)
  • Use one LED as an output (o)
  • Use two buttons, button one for selecting an LED, button two for toggling an LED (on/off, HIGH/LOW)

The following criteria must be met:

"By pressing button one the user enters an 'input mode'. All input LEDs will fade down to a low brightness and the first input is selected. By pressing button two the LED can be toggled on/off. By pressing button one again the second LED is selected, etc (until LED 4). After passing the 4th LED the user automatically exits the 'input mode'. After this the output is calculated and shown by the output LED."


I put the criteria in steps to make it easier for both myself and you:

Step one: User presses button one; input LEDs 0, 1, 2, 3 (i1, i2, i3 and i4) brightness lowers
Step two: User presses button two; user can toggle 0, 1, 2, 3 off and on
Step three: After user configures the last button the LEDs go back to full brightness
Step four: Arduino calculates the output. If output is true then the output LED goes on

This is the code I have so far:

int led0 = 9;         //I1 LED
int led1 = 10;        //I2 LED
int led2 = 11;        //I3 LED
int led3 = 12;        //I4 LED
int ledOutput = 13;   //output LED
int button1 = 2;      //button1 button
int button2 = 3;      //button2 button

boolean t1, t2, t3, output;
boolean i1, i2, i3, i4;

void setup() {

  pinMode(led0, OUTPUT);
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(ledOutput, OUTPUT);
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);

}
void loop() {

  t1 = !i1;
  t2 = t1 && i2;
  t3 =  i3 || i4;
  output = !t2 || !t3;

  if (output == true) {
    digitalWrite(ledOutput, HIGH);
  }
}

I tested the calculation by declaring i1, i2, i3 and i4 false and I'm getting a "true" output, so the schema is correct.

I need to be able to set i1, i2, i3 and i4 true or false using the buttons. Remember; button 1 to switch i1, i2, i3 i4, button 2 to toggle true/false. After finishing "i4" the arduino then calculates and depending on the result, output is shown (or not shown).

Hopefully someone is able to help me. May you need any more information then please let me know, I'll be more than happy to provide all information.

(deleted)

spycatcher2k:
Hi - I'm sorry, but we don't do homework here.

I'm not asking you to do homework, I'm asking for assistance. Also whether this is homework or something I came up with myself, what would it matter?

Processorkoeler:
Also whether this is homework or something I came up with myself, what would it matter?

Because when we do your homework for you, then we one day may have to deal with you as an employee who doesn't know how to do things without someone doing them for you. You're in school to learn, not to just get As at any cost. Sometimes failing is part of learning.

HINT: A NOR B is not the same as !A OR !B. Think about it. If A was false and B was true, then NOT A OR NOT B becomes true OR false which is true. That's not a NOR gate. You need them both to be false.

It matters because in school you have a teacher or a professor with whom you are supposed to have a discussion. If you came up with this yourself, you would have only us for a discussion. Furthermore, we do not want to help with any cheating.

How are your buttons or switches wired?

vaj4088:
It matters because in school you have a teacher or a professor with whom you are supposed to have a discussion. If you came up with this yourself, you would have only us for a discussion. Furthermore, we do not want to help with any cheating.

How are your buttons or switches wired?

Why would this be cheating? I’m asking for support. Teacher emphatically told us to help each other; I’m seeking help through the Arduino forums. I also didn’t just throw down the assignment on my begin post and ask for anyone to solve it for me. I’ve shown what I’ve done so far, what I don’t understand and what I think needs to be done.

Wires:

I have a terrible camera so explained in text:

LED 0, 1, 2, 3 are connected on pin 9, 10, 11, 12
output LED is on pin 13
Button1 is on pin 2, button 2 is on pin 3,

Processorkoeler:
Why would this be cheating? I'm asking for support. Teacher emphatically told us to help each other; I'm seeking help through the Arduino forums.

That's what they all say. But as soon as someone gives them an answer they run and hand that in. And then they learn nothing. And then we end up with programmers with degrees that don't know how to program. You can argue until you are blue in the face but you're not going to convince this crowd that is a good idea. We just don't do your homework for you. You should do your own homework.

I pointed out where your problem is. You need to focus less on the cheating thing and more on the answer I already gave you.

void loop() {

  t1 = !i1;

What is the value of “i1” at this point?
Why?

Teacher emphatically told us to help each other

He told that to your class; we didn't get the message here.

AWOL:

void loop() {

t1 = !i1;



What is the value of "i1" at this point?
Why?

Each "t" is a gate, I figured it'd be easy and clear to show all t's and i's. t1 is required for t2.

Delta_G:
That's what they all say. But as soon as someone gives them an answer they run and hand that in. And then they learn nothing. And then we end up with programmers with degrees that don't know how to program. You can argue until you are blue in the face but you're not going to convince this crowd that is a good idea. We just don't do your homework for you. You should do your own homework.

I pointed out where your problem is. You need to focus less on the cheating thing and more on the answer I already gave you.

All you're doing is telling me to figure it out myself. Like I said; I'm not expecting anyone here to do it for me. I need help doing this and pointed to where my problem is. I've shown what I've got so far aswell.

Other than the output statement being wrong ( output = !t2 || !t3;) you didn't say anything else other that than I'm cheating if I were cheating I'd ask "please do this assignment for me so I can turn it in".

I can figure out the output but I have no idea how to do the button switching. Arduino has built-in examples and I can't figure out what they represent compared to what I need to do to get this working.

If no one is able to 'push me in the right direction' how am I supposed to ever figure it out myself? This is not cheating, I'm asking for assistance. If you don't want to help at all, fine then, but don't reply by saying "do it yourself, good luck, you're cheating".

Each "t" is a gate, I figured it'd be easy and clear to show all t's and i's.

You didn't answer my question, so I'll repeat it - What is the value of i1?
If you think a little harder about that question (and, of course, its answer), you may start to make some progress.

I did push you in the right direction. But you have your panties in such a bunch because nobody wants to just do it for you that you won't look. Read what I told you. The answer is there but you're going to have to put in a little thought. I didn't just write it out in code. But I did tell you exactly how to fix that line. If you can't get it from there then you probably do need to fail so the instructor knows that you need some extra attention.

You need for BOTH to be false for a NOR gate to say true. Read what I wrote and THINK ABOUT IT for just a minute and you'll see.

Right now you are showing that you are just what we thought. You aren't putting in much effort to solve this, you want someone to spit out an answer for you. You don't want a push. I gave you a big push. But I didn't just write the answer out for you so you say I'm no help.

And AWOL's question is important too. What is the value of i1 in that program? Not what did you mean for it to represent. But what VALUE does it have in your code? What does i1 equal?

AWOL:
You didn't answer my question, so I'll repeat it - What is the value of i1?
If you think a little harder about that question (and, of course, its answer), you may start to make some progress.

Sorry for the slow replies, I can only reply every 5 minutes.

i1 can be true or false (on/off) depending on the given input, on default it'd be false.
i1 equals a boolean value.

I didn't ask what it can be, because that's a pretty short list, I asked what its value is

OK, I also asked how it got whatever value it has.

For some time to come, you have five minutes between posts. How about using those five minutes to think?

Processorkoeler:
Sorry for the slow replies, I can only reply every 5 minutes.

i1 can be true or false (on/off) depending on the given input, on default it'd be false.
i1 equals a boolean value.

What input? You never read any inputs in your code.

AWOL:
I didn't ask what it can be, because that's a pretty short list, I asked what its value is

OK, I also asked how it got whatever value it has.

For some time to come, you have five minutes between posts. How about using those five minutes to think?

The value is false. The way it got the value it has (false) is because the default value of a boolean is false.

I always have trouble interpreting stuff, I'm sorry. With programming I suppose I have to get used to takings things literally.

I also solved the issue for output: output = !t2 && !t3;
As you said both of them need to be false to get a true output. || is OR, && is AND.

Delta_G:
What input? You never read any inputs in your code.

The way I do it is now is by manually typing the values. Example:

i1 = false;
i2 = false;
i3 = false;
i4 = false;

Because I do not know, thus I have to figure out, how to combine an LEDstatus to the boolean value. And with the button I need to configure the LEdstatus (on/off).