BulldogLowell:
It may be the way you wrote it. But, you’ve not shown how you write it!The devil is in the details.
hi sir i wrote out the code, but only for this particular section i posted that i am unsure about. Sorry ;p
MorganS:
This code will make pin 2 a floating input. If it's not connected to anything then it will pick up stray electrical fields from the air and can read high or low at random.Also, why are you writing to an input?
that might be where i went wrong.
I wrote to the input because i thought the arduino board can read inputs
by making 4 the output, it (4) can send an electrical signal to the input (2) and thus the if statement comes in to check the condition if(digitalRead(2) == HIGH) is being fulfilled.
i am still trying to understand how circuits work and yes kind sir, is there a way you can advise me on to make sure what I am planning to do works.
sorry for any confusion guys!