I have a knex roller coaster project, where i have wired loads of motors to my arduino uno, and controls them. I also have a magnet stuck underneath the train, which trips a magnetic reed switch, so i can make the motors respond. The switch works perfectly fine, but the pin constantly gives random input. I have
tried both connecting the input pin to ground (through a resistor) using both digital and analog, but nothing changed.
bool passed = false;
while (!passed)
{
int i = analogRead(SENS1);
Serial.println(i);
if (i == 1)
{
Serial.println("Test");
passed = true;
}
}
However, i am getting random input all the time! The reading the sensorpin will sometimes randomly read high.
I have read around floating input, and have found some good answers, but nothing is working for me!
(I've attached a photo of my Arduino setup)
It's basically the exact same as the one in this tutorial
No it is not. The one on the tutorial uses a digitial input like the ones used in LarryD's schematic.
Yours uses an ANALOG input.
They are COMPLETELY DIFFERENT !
I have built myself up from the basics... but haven't learnt much. I've had lots of success with slightly simpler projects in the past, like rigging up an automatic nerf gun, but this problem is just bugging me.
I've probably just missed out on something simple.
I'll try those schematics that LarryD posted, and get back to you on the results.
You can use most analog inputs as digital inputs - that should be OK
I don't think that's the point. He is using analog code with an analog input for a digital type input wiring that he copied from a tutorial but changed the code to analog code.
Hi,
Do you have a DMM to measure voltages around your circuit.
What is the voltage on the input pin of the Arduino when the switch is open and when it is closed with respect to gnd?