// 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?
some reason i cant see this thread on forums..
test post
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
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
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
Unfortunately, I can not help you! I'm not good at this. Sorry!((
sprint corporate