Starter kit lesson 5 digital input button issue

Hello,

I am working on the mega 2560 most complete starter kit lesson 5 digital input using two push buttons to control the led light. I wired the project exactly like the tutorial (I believe so) as the tutorial. the leg of resistor is not very clear but one is in the same column with the led light, another is same column as the red wire.

Once done, I found that my left button turn off the light when pushed done but the light is back on when released. My right button does nothing. The light is on no matter if i push it or not.

Is this correct? I feel it is not. But i am not sure which part is wrong.
Thanks!

Post your formatted code and a wiring diagram.

Remember your last "Pitches.h" problem... it was a copy/paste problem at your fingertips. Be sure you have typed in the code correctly.

GitHub with 223 page User Manual and code in text form.

Please post schematics showing how You wired things. That picturre is not good enough.

The photo does not match the diagram...


Or the code...

//www.elegoo.com
//2016.12.08

int ledPin = 5;
int buttonApin = 9;
int buttonBpin = 8;

byte leds = 0;

void setup() 
{
  pinMode(ledPin, OUTPUT);
  pinMode(buttonApin, INPUT_PULLUP);  
  pinMode(buttonBpin, INPUT_PULLUP);  
}

void loop() 
{
  if (digitalRead(buttonApin) == LOW)
  {
    digitalWrite(ledPin, HIGH);
  }
  if (digitalRead(buttonBpin) == LOW)
  {
    digitalWrite(ledPin, LOW);
  }
}
//www.elegoo.com
//2016.12.08

int ledPin = 5;
int buttonApin = 9;
int buttonBpin = 8;

byte leds = 0;

void setup() 
{
  pinMode(ledPin, OUTPUT);
  pinMode(buttonApin, INPUT_PULLUP);  
  pinMode(buttonBpin, INPUT_PULLUP);  
}

void loop() 
{
  if (digitalRead(buttonApin) == LOW)
  {
    digitalWrite(ledPin, HIGH);
  }
  if (digitalRead(buttonBpin) == LOW)
  {
    digitalWrite(ledPin, LOW);
  }
}

Your wiring shows pin 7.

Wow you guys are good! Thanks!!!
I now fixed that. Now the issue is

  1. the light is on when i plugged in the board, not like the example that the light is off first, and response to left button to be on, right button to be off

Arduino Elegoo MEGA 2560 lesson 5 Digital Inputs

  1. My left button still performs same as before that press ->off, release0>on,
  2. my right button is now is doing sth, when pressed, the light dim a little, when released, back to original on status
  3. Also tried sth with the red wire, when removed, my light is still on, only dimmer.

You should start from everything removed. When you re-assemble it, be very attentive. The code is right, the drawing is right, the only thing that remains is you.

???

means something, sorry

this is the sample wiring pic from the toturial
(THis is not mine, this is sample!)

okay, will try again

You do not want to assemble electronics by looking at a picture. You want to reference the wiring diagram.

Yes you are right, but i am still learning and sometimes i do not understand everything in the diagram yet :frowning:

This is physically not possible with the circuit in the photo that you posted above.

If you have modified your circuit, please post a new picture (or better, draw a diagram).

That is good. We all should continue to learn, always. Know when to ask questions, which might be difficult ("What question do I ask?"... "All of them.") With learning and practice, you will be independent.

I fixed it, i am taking picutre and will show what changes i made, then trying to figure out what is wrong.

first pic is wrong setup
Second is correct.

right leg of the led light,
position of resistor
and starting point of the red wire changed


is there a software to use to draw the diagram?

There are lots of systems for it but pen and paper usually works well. A phone, a picture and posting does the rest.

If you prefer not to draw by hand, I found the following web tool very easy to learn:

There are ways to download your diagrams, but for purposes of the forum, it would be simpler just to screenshot any diagrams that you make using circuit-diagram.org.