good day everyone, can you please help me about on this problem, i do and research some related topic on this and i didnt make it i do only on off of 1 led using 1 pushbutton. can you please help me what im gonna code on coz im not good in programming.
i have 1 led and two button switch (pushbutton 1 and pushbutton 2). the flow of code is this.
when i "run/compile" the state of led is "off" and when i press whether pushbutton 1 or pushbutton 2 the led will on. and the when the led is on when i press whether pushbutton 1 or pushbutton 2 the led will go off
here is the schematic diagram that i see on net but i im not sure if it is the same schematic diagram that i will use too.
Write the code which will turn one led on and off with one button in the manner you want. The StateChangeDetection example in the ide 02Digital examples section will be a good place to start.
When you get done, you will see that there are some conditional statments like
if (digitalRead(some button pin) == some value dependent upon your wiring){
//take some action
}
When you have the one button code you want, take a look at the boolean "logical or" operator
digitalRead is true or false, so you could use it directly.
if (digitalRead(3)==HIGH) is the same than if (digitalRead(3))
Do you actually think I don't know this?
I am explaining things for a beginner and it is my opinion that what I wrote is a lot clearer that what you wrote. Clarity is important when you are learning concepts for the first time. Once you have that under your belt you can get "clever" but beware creating elegance.
Grumpy_Mike:
Do you actually think I don't know this?
I am explaining things for a beginner and it is my opinion that what I wrote is a lot clearer that what you wrote. Clarity is important when you are learning concepts for the first time.
I'm sorry I didn't want to be unpleasant. I understand now what you meant.