Society of Robots - Robot Forum
Electronics => Electronics => Topic started by: blackheart on March 19, 2009, 12:32:50 PM
-
Hello! I just plugged in my sharp IR sensor in my arduino. I soldered on the connectors, so it may not be a good connection if that will help troubleshoot! I user this function to calculate the output of the sensor into cm.
float read_gp2d12_range(byte pin) {
int tmp;
tmp = analogRead(pin);
if (tmp < 3)
return -1; // invalid value
return (6787.0 /((float)tmp - 3.0)) - 4.0;
}
And I can see it works. I just put my hand in front of it and moved it farther away, or closer to the sensors. It gave me almost correct numbers.
But sometimes, I just get weird symbols that I can't even type with my keyboard.
like a square and many others! Could the possibly bad soldering be the problem?
-
Hi,
But sometimes, I just get weird symbols that I can't even type with my keyboard.
like a square and many others! Could the possibly bad soldering be the problem?
Nope, your routine should only output numbers, no matter if you used duct tape.
I think you should take a closer look at, how you interpret the output from your routine and what you do to output the result.
-
Enlighten me, please!
Forget the whole conversion function. Even if I just analogRead(0); considering the fact that the sensor is plugged in pin 0 analog and output it to the screen, I get these weird-ass symbols.
The funny thing is that it used to work. Oh, and it can't be from bad soldering. I just re-soldered it correctly.
-
Guys, I love you!
I was mixing up CCS C and Arduino C.
It's not Serial.write, it's Serial.println()
It works...FLAWLESSLY!
-
Is IR light from the sensors harmful to my eyes. I looked into the IR transmitter in the sensor and now I see everything blurry!
-
I don't think it is harmful, but I am not sure. Go to sleep and if you are blind when you wake up, go to the eye doctor.