go_away

Author Topic: Weird symbol readings from sharp IR  (Read 1265 times)

0 Members and 1 Guest are viewing this topic.

Offline blackheartTopic starter

  • Full Member
  • ***
  • Posts: 111
  • Helpful? 1
Weird symbol readings from sharp IR
« 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?
I'm out of ideas!

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Weird symbol readings from sharp IR
« Reply #1 on: March 19, 2009, 02:59:57 PM »
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.
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline blackheartTopic starter

  • Full Member
  • ***
  • Posts: 111
  • Helpful? 1
Re: Weird symbol readings from sharp IR
« Reply #2 on: March 19, 2009, 04:56:02 PM »
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.
I'm out of ideas!

Offline blackheartTopic starter

  • Full Member
  • ***
  • Posts: 111
  • Helpful? 1
Re: Weird symbol readings from sharp IR
« Reply #3 on: March 19, 2009, 05:07:28 PM »
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!
I'm out of ideas!

Offline blackheartTopic starter

  • Full Member
  • ***
  • Posts: 111
  • Helpful? 1
Re: Weird symbol readings from sharp IR
« Reply #4 on: March 19, 2009, 05:09:03 PM »
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'm out of ideas!

Offline offy

  • Supreme Robot
  • *****
  • Posts: 340
  • Helpful? 1
Re: Weird symbol readings from sharp IR
« Reply #5 on: March 19, 2009, 06:13:14 PM »
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.

 


Get Your Ad Here

data_list