Hi guys I want to build senso so I started first to put everything together and then start programming.
So i put 4 buttens and 4 lamps on a breadboard.
Iconected 1 leg of each button with a digital port 1leg with 5V 1 leg with a resitor and then ground and 1 leg is unconnected.
I programmed first 1 button so i push it I see it on the serial monitor. I only wrote this code for 1 button, but when I press no matter which button it reacts where is my fault?
Reading that I have no idea how things are wired. This is where a drawing of your circuit, even a hand drawn image along with posting your code would go a long way. I have no idea based on your post what is causing your problem.
Ron
It appears you are going to short the power rails when a switch is closed.
LEDs need series dropping resistors.
Show us a good schematic of your circuit.
Show us a good image of your wiring.
Give links to components.
Posting images:
https://forum.arduino.cc/index.php?topic=519037.0
Use CTRL T to format your code.
Attach your ‘complete’ sketch between code tags, use the </> icon in the posting menu.
[code]Paste your sketch here[/code]
The way to remember how to wire those button switches is two wires only, across a diagonal.
Then you don't have to remember which pairs of pins are commoned-up in the switch. (Though you
can check this with a multimeter if you want).
Wire one side of button to ground, the other to a pin, use pinMode (pin, INPUT_PULLUP); in the
setup() function.
The the pin will read LOW when the button is pressed, HIGH otherwise. A helper function can make
this easier to follow in your code:
bool is_pressed(byte button)
{
return digitalRead (button) == LOW ; // return true if button pressed and connects pin to ground.
}
....
if (is_pressed (button1))
{
....
}
That way the rest of the code doesn't have to know about the sense of the button pins, and will
be easy to read due to the "is_pressed" function name being meaningful
See this post: Button FAQ: common mistake - button does NOT work as expected. - Introductory Tutorials - Arduino Forum
Hi,
Welcome to the forum.
Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Please NO FRITZY picture.
I see NO RESISTORS, where are the LED current limit resistors and the pull-down resistors for the buttons.
Do you have a DMM?
Tom... ![]()
