Society of Robots - Robot Forum

Software => Software => Topic started by: Razor Concepts on October 07, 2008, 05:56:44 PM

Title: Sharp Code for GP2Y0A21YK
Post by: Razor Concepts on October 07, 2008, 05:56:44 PM
Hi, I just bought the Sharp IR sensor, the GP2Y0A21YK version (for my Axon). I noticed in sensors.c , there is no mention of the GP2Y0A21YK, closest one is the GP2Y0A02YK, which doesnt seem to work well. What code would be appropriate for my Sharp sensor? Thanks  ;D
Title: Re: Sharp Code for GP2Y0A21YK
Post by: Admin on October 07, 2008, 10:41:49 PM
Ok I just wrote this code for you. Add it into sensors.c. It'll be included in all future Axon code versions. Let me know how well it works for you!

Code: [Select]
//Sharp GP2Y0A21YK IR Range Sensor - 4 cm to 30 cm
int sharp_IR_interpret_GP2Y0A21YK(int value)
{
return 739.38*pow(value,-.8105);
}
Title: Re: Sharp Code for GP2Y0A21YK
Post by: Razor Concepts on October 08, 2008, 04:59:43 PM
Thanks it works great. This also spurred me on to finally use the hyperterminal... and now I wish I had used it earlier, it should help a lot in trying to debug my code  ;D