keyestudio
www.keyestudio.com
Sample Code:
*******************************************************************************
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#define SensorLeft 6 //input pin of left sensor
#define SensorMiddle 9 //input pin of middle sensor
#define SensorRight 11 //input pin of right sensor
unsigned char SL; //state of left sensor
unsigned char SM; //state of middle sensor
unsigned char SR; //state of right sensor
#define Lpwm_pin 5 //pin of controlling speed---- ENA of motor driver board
#define Rpwm_pin 10 //pin of controlling speed---- ENA of motor driver board
int pinLB=2; //pin of controlling diversion----IN1 of motor driver board
int pinLF=4; //pin of controlling diversion----IN2 of motor driver board
int pinRB=7; //pin of controlling diversion----IN3 of motor driver board
int pinRF=8; //pin of controlling diversion----IN4 of motor driver board
unsigned char Lpwm_val =180;//the speed of left wheel at 180 in initialization
unsigned char Rpwm_val = 180;//the speed of right wheel at 180 in initialization
int Car_state=0; //state of car moving
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2
void LCD1602_init(void)
{
lcd.init();