Smackflad:
I have tried to do the third and failed because when I turn off the switch the relay won't turn the light on. But the opposite works.
I have also tried to do the second and make the switch to send signal to the arduino so it can control the relay but when the switch is off it sends random 1s and 0. When the switch is on is correct and send only 0. If I fix this the project will be solved.
Now try it OUR way.
create a sketch. show the wiring. black is hot, RED is switched and white is neutral.
no amount of words will help as fast as one sketch.
in your case, you need to show us how you did it both ways.
we all do a sketch, paper and pencil or on the computer, when we run into something that we need to figure out.
is sounds like a simple wiring issue.
google LADDER LOGIC
it is how electricians look at the work.
the sketch shows a receptacle in parallel to the light. this way, you can plug in your phone charger to sense the 5v when power is on.
