Using the ET Sensor

5 replies [Last post]
Millburn1
Title: NooBot
Joined: 02/04/2013
Posts:
BotPoints: 22
User offline. Last seen 10 years 5 weeks ago.

// Created on Sat March 23 2013
// the purpose of this program is to make the ET sensor work
// for the sensor to work, the sensor values must return floats, and the default is to return ints
// this program changes a specified analog port to return float values, and display them until a button 'stop' is pressed
// keywords: ET sensor, float, port
int main()
{
int port = 0; // what port should be changed to float
set_analog_pullup(port, 0); // (port #, 0 for float or non0 for ints)

set_a_button_text("Stop");
while (!a_button()) // while a button is not pressed
{
printf("%f\n", analog10(port));
msleep(1000);
}
printf("Code finished executing.\n");
return 0;
}

The ET sensor is plugged into port 0.
We want it to be sort of like a distance sensor, knowing how far away it is from something it could potentially bump into (pvc pipes).
When this code is run, the program prints .0000 over and over again, even though we put stuff in front of the sensor a millimeter in front, or have nothing in front of it.

Is there something we're doing wrong?

Millburn1
Title: NooBot
Joined: 02/04/2013
Posts:
BotPoints: 22
User offline. Last seen 10 years 5 weeks ago.

some reason i cant see this thread on forums..
test post

Jeremy Rand
Jeremy Rand's picture
Title: Botball Youth Advisory Council
Joined: 04/03/2009
Posts:
BotPoints: 1168
User offline. Last seen 8 years 2 weeks ago.

Sorry about that, the spam filter erroneously flagged your post as spam. I've unflagged it. Feel free to contact me in the Botballer's Chat if it happens again.

-Jeremy Rand
Senior Programmer, Team SNARC (2012-2013), Norman Advanced (2010-2011), Norman HS (2008-2009), Norman North (2005-2007), Whittier MS (2003-2004)
2012-2013 VP of Tech, 2011 President, Botball YAC (2009-2013)
Mentor, Alcott and Whittier MS

Jeremy Rand
Jeremy Rand's picture
Title: Botball Youth Advisory Council
Joined: 04/03/2009
Posts:
BotPoints: 1168
User offline. Last seen 8 years 2 weeks ago.

All analog-to-digital converters (ADC's) return an integer. The set_analog_pullup function is used to enable or disable pullup circuitry (when the pullup is disabled, the port is considered "floating" in an electrical sense). If you replace the %f in your printf string with %d, it should work.

-Jeremy Rand
Senior Programmer, Team SNARC (2012-2013), Norman Advanced (2010-2011), Norman HS (2008-2009), Norman North (2005-2007), Whittier MS (2003-2004)
2012-2013 VP of Tech, 2011 President, Botball YAC (2009-2013)
Mentor, Alcott and Whittier MS

Ponivnret
Title: NooBot
Joined: 07/29/2016
Posts:
BotPoints: 22
User offline. Last seen 6 years 44 weeks ago.

This is really good information I have visited this blog to read something fresh and I really admire you efforts in doing so.
192.168.o.1

panistefanin
Title: NooBot
Joined: 05/29/2017
Posts:
BotPoints: 64
User offline. Last seen 4 years 51 weeks ago.

Unfortunately, I can not help you! I'm not good at this. Sorry!((
sprint corporate