Were using a potentiometer and I have no idea how to read the potentiometer value!
PLease help
Were using a potentiometer and I have no idea how to read the potentiometer value!
PLease help
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.
So i just printf(“Pot %d\r”, Get_Analog_Value(rc_ana_in0*)); to display it?
Yes that should do it.
Well, to clarify, you would replace * with the number of the analog input you put the potentiometer into. For example, if you plugged the potentiometer into analog input 1, you would put
printf("Pot %d\r", Get_Analog_Value(rc_ana_in01));
But you may have already known that.
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
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
Yep, Get_Analog_Value(‘the analog input number’).