Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
M3pi Class Reference
m3pi control class More...
#include <m3pi.h>
Public Member Functions | |
| M3pi () | |
| Create the m3pi object connected to the default pins. | |
| M3pi (PinName nrst, PinName tx, PinName rx) | |
| Create the m3pi object connected to specific pins. | |
| void | reset (void) |
| Force a hardware reset of the 3pi. | |
| void | stop () |
| This function will smoothly stop the motors of the robot by gradually slowing down. | |
| void | activate_motor (int motor, float speed) |
| Activate motor. | |
| void | raw_sensors (int sensors[5]) |
| Reads the values of the active light sensors. | |
| void | calibrated_sensors (int sensors[5]) |
| Reads the values of the active light sensors. | |
| float | battery (void) |
| Read the battery voltage on the 3pi. | |
| char | sensor_auto_calibrate (void) |
| Calibrate the sensors. | |
Detailed Description
m3pi control class
Definition at line 26 of file m3pi.h.
Constructor & Destructor Documentation
| M3pi | ( | ) |
| M3pi | ( | PinName | nrst, |
| PinName | tx, | ||
| PinName | rx | ||
| ) |
Member Function Documentation
| void activate_motor | ( | int | motor, |
| float | speed | ||
| ) |
Activate motor.
- Parameters:
-
motor. Values: 0: Left; 1: Right speed Float value representing the speed of the motor. Negative values will turn the wheels in reverse. The possible values of this parameter range between -1 and 1. The values are normalized, so speed=1 means the motor will activate at full (100%) power, while speed=0.2 would activate the motor with 20% of its maximum power. A good starting value can be speed=0.1. In most cases the speed value you will use should be between -0.5 and 0.5.
| float battery | ( | void | ) |
| void calibrated_sensors | ( | int | sensors[5] ) |
Reads the values of the active light sensors.
The result values are normalized in the range 0-1000 based on the calibration. The function sensor_auto_calibrate() should be called once at the start of the program before reading the calibrated values.
- Parameters:
-
sensors Array of 5 int elements that will be populated with the sensor values
| void raw_sensors | ( | int | sensors[5] ) |
| char sensor_auto_calibrate | ( | void | ) |
Calibrate the sensors.
This turns the robot left then right, looking for a line. Make sure that when this function is called, the robot is positioned on the black line on white background. The values of the calibration are storred internaly and used when computing the normalized result values of calibrated_sensors().
Generated on Sun Jul 17 2022 07:37:17 by
1.7.2