Thank you, I am getting more accurate readings from the Switch.
This is nonsense.
The Arduino input pin is floating. No matter how many times you use analogRead() you will never get a stable value, because your circuit is not stable.
Simply connect the switch between the arduino pin and ground. Use pinMode(x, INPUT_PULLUP) and digitalRead(). Simple.
The way you had it your pin will float.
Just use
switchState = digitalRead(A1);
OR
switchState = digitalRead(15);
You were 100% correct.
Your topic was moved to its current location as it is more suitable.
Could you also take a few moments to Learn How To Use The Forum.
It will help you get the best out of the forum in the future.
Thank you
Thank you @PaulRB.. I got the proper connection and getting the values.
The next question is why you are using an Arduino? The Pi is quite capable of reading a switch without help from an Arduino.
Well, that wasted 30 minutes of my time...
No! you assured your place in the line at the pearly gates
I thought we all got a place in line⦠just not necessarily passage when we get to the front.
a7
I am planning to use Arduino MKR1010 at a distant place and PI as a Server, and need to get the input from Arduino to PI.
@LarryD Thank you for your help..
You could also consider wemos D1 mini.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.