![]() |
Help! Analog Inputs!!
Were using a potentiometer and I have no idea how to read the potentiometer value!
PLease help |
Re: Help! Analog Inputs!!
Simply plug your POT into a analog port
Then use Get_Analog_Value(rc_ana_in0*) Where * is the number port you placed the POT. It will return a value between 0 and 1024, depending on how far it has been turned. |
Re: Help! Analog Inputs!!
So i just printf("Pot %d\r", Get_Analog_Value(rc_ana_in0*)); to display it?
|
Re: Help! Analog Inputs!!
Yes that should do it.
|
Re: Help! Analog Inputs!!
Quote:
Code:
printf("Pot %d\r", Get_Analog_Value(rc_ana_in01)); |
Re: Help! Analog Inputs!!
It doesn't really matter in this case, but when using an unsigned value, like analog inputs, you should use %u and not %d (the ADC conversion gives you a 10-bit value, 0-1023, so it should never come up as negative, but it's good to know in case you need a full 16-bit unsigned int).
Just make sure that the pot is properly connected (red + black leads to the outer leads on the pot, white to the wiper/middle lead) and you should have no problems. Our arm potentiometer got disconnected during testing and its value started creeping by 1 every few seconds, it was really weird. O_o |
Re: Help! Analog Inputs!!
Also, make sure you've included ifiutilities.h in whatever file you're using Get_Analog_Value() or else it won't work. o_o
|
Re: Help! Analog Inputs!!
Yep, Get_Analog_Value('the analog input number').
|
| All times are GMT -5. The time now is 04:47. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi