Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 2 months ago.
m3pi sensors
Hello !!
I'am a new user of "Pololu m3pi" , I need to access to the state of the five sensors in order to solve a maze.
This is the function that I used:
unsigned short capteurs[5]; unsigned char vecteur;
void stockage_capteurs() { m3pi.cls(); m3pi.locate(0,1); m3pi.printf("sensors"); m3pi.calibrated_sensors(capteurs); vecteur = (capteurs[0]>500)*1+ (capteurs[1]>500)*2+(capteurs[2]>500)*4+(capteurs[3]>500)*8+(capteurs[4]>500)*16; } In order to turn left or right I used an if condition kind of :
if(capteurs[0]==1 && capteurs[4]==0) { m3pi.cls(); m3pi.locate(0,1); m3pi.printf("Left"); m3pi.stop(); m3pi.left_motor(left); } if(capteurs[0]==0 && capteurs[4]==1)
{ m3pi.cls(); m3pi.locate(0,1); m3pi.printf("Right"); m3pi.stop(); m3pi.right_motor(right); } But the robot does not respect the conditions.
I will be so greatful if you have an idea about how can I solve it.
Thanks!!
1 Answer
10 years, 1 month ago.
See this : https://developer.mbed.org/questions/68240/Problem-in-function-calibrated_sensors/ It can be helpful :)