im new to Arduino (especially the code bit) so be prepared for a stupid question...
i am trying to write code so that when the Arduino detects a signal (5v) on the analog pin (A0 to be exact), it responds by outputting 5v from one of the digital pins (2). This is just to get the concept working, and then i can expand it so lots of things happen when the board senses a 5v signal on one of the pins. (Could really be any, i am using Analog atm).
This is probably totally wrong, pls correct me...
( i have tried loads of different combinations in the code, swapping alias names for pin numbers etc... Also, if you are wondering what all that about LCD is, i have an LCD connected to the Arduino that i am using, however right now this is not relevant or doing anything, just trying to get the above mentioned concept working.)
You're almost never going to get exactly 900. Usually with anything analog you should use less-than or greater-than, or both if you want to check for a range of values.
With 5V you'd expect to read 1023 but voltages can vary and the ADC isn't always "perfect" so you might read something a little lower.
Just FYI - With digital signals there is also a "range" of voltages... The Aruduino reads anything greater than 3V as high and anything less than 1.5V as low. In-between is undefined and it might read high or low.
Hint - For troubleshooting & debugging, it's helpful to "print-out" variables (or other little messages) to the serial monitor (or to the LCD once you get it working). This allows you to "see" the analog value, etc., and as your program gets more complicated you can add little messages like, "Reading analog input", again to "see" what your program is doing, especially when it's not behaving as expected.
i don't have it connected to anything new, what i mean, is i have a jumper wire in the A0 header pin thing, and if you touch that with your bare finger, the reading can get very high, (900+), according to the serial monitor.
This is not a huge issue, however (relevant or not), can someone please explain what pull up resistors are on the board? i have heard of them, but have no clue...
Well, it turns out i have figured out the problem with all the noise and false alarms, using a ground connection, a 1M ohm resistor, however it would be helpful if someone could still explain the pull up resistor thing, just for future knowledge.
Sure, what pull up resistor thing? You only referred to, "the Arduino that I'm using" so we don't know which one. But none that I know of have any on board resistors on the analog inputs. You can enable internal pull up resistors on analog inputs on the AVR at least, usually not a good idea.
I looked back through the thread and couldn't find any mention of pull up resistors...
Also you neglected to explain what you are planning to connect this to.