The Makerlabvn_I2C_Line_Follower_Sensor library allows you to interface with the Makerlabvn I2C Line Follower Sensor using Arduino. This sensor helps in detecting lines on the ground, which is useful for line-following robots.
- Open the Arduino IDE.
- Go to
Sketch>Include Library>Manage Libraries.... - In the Library Manager, search for
Makerlabvn_I2C_Line_Follower_Sensor. - Click on the library and install it.
Here is a simple example to get you started:
#include "Makerlabvn_I2C_Line_Follower_Sensor.h"
Makerlabvn_I2C_Line_Follower_Sensor LineFollowSensor;
void setup()
{
Serial.begin(115200);
LineFollowSensor.setup(0x2A);
}
void loop()
{
/************ SENSOR *************/
/*-------------------------------*/
/* |LEFT| P1 P2 P3 P4 P5 |RIGHT| */
/* 0b 1 1 1 1 1 */
/* 0: White; */
/* 1: Black */
/*-------------------------------*/
LineFollowSensor.getData();
Serial.print("P1:");
Serial.print(LineFollowSensor.getValue(0));
Serial.print(" P2:");
Serial.print(LineFollowSensor.getValue(1));
Serial.print(" P3:");
Serial.print(LineFollowSensor.getValue(2));
Serial.print(" P4:");
Serial.print(LineFollowSensor.getValue(3));
Serial.print(" P5:");
Serial.print(LineFollowSensor.getValue(4));
Serial.print(" data:");
Serial.println(LineFollowSensor.getValue(), BIN);
delay(50);
}Initializes the sensor with the specified I2C address.
- Parameters:
address(uint8_t): The I2C address of the sensor. (From 0x2A to 0x2E), setup by Double-Click then Long Press button S1 on the sensor
Reads the sensor data and updates the internal state.
Returns the value of the sensor at the specified position.
-
Parameters:
position(uint8_t): The position of the sensor (0 to 4).
-
Returns:
uint8_t: The value of the sensor at the specified position (0 for white, 1 for black).
Returns the combined value of all sensors as a single byte.
- Returns:
uint8_t: The combined value of all sensors in binary format.
This library is licensed under the MIT License. See the LICENSE file for more details.
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
For any questions or feedback, please contact contact.makerlabvn@gmail.com.