EasyManua.ls Logo

Keyestudio 4WD Bluetooth Multi-functional Car - Page 107

Keyestudio 4WD Bluetooth Multi-functional Car
151 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
keyestudio
www.keyestudio.com
105
Sample Code
******************************************************************************
#include <LiquidCrystal_I2C.h> //including libraries of I2C-LCD1602 liquid crystal
#include <Wire.h> //including libraries of I2C
//////////////////////////////////////////////////
int inputPin=A0; // ultrasonic module ECHO to A0
int outputPin=A1; // ultrasonic module TRIG to A1
LiquidCrystal_I2C lcd(0x27,16,2); //defining liquid crystal
#define Lpwm_pin 5 //pin of controlling speed---- ENA of motor driver board
#define Rpwm_pin 10 //pin of controlling speed---- ENB of motor driver board
int pinLB=2; //pin of controlling turning---- IN1 of motor driver board
int pinLF=4; //pin of controlling turning---- IN2 of motor driver board
int pinRB=7; //pin of controlling turning---- IN3 of motor driver board
int pinRF=8; //pin of controlling turning---- IN4 of motor driver board
unsigned char Lpwm_val = 250; //initialized left wheel speed at 250
unsigned char Rpwm_val = 250; //initialized right wheel speed at 250
int Car_state=0; //the working state of car
int servopin=3; //defining digital port pin 3, connecting to signal line of servo motor
int myangle; //defining variable of angle
int pulsewidth; //defining variable of pulse width
unsigned char DuoJiao=60; //initialized angle of motor at 60°
void servopulse(int servopin,int myangle) //defining a function of pulse
{
pulsewidth=(myangle*11)+500; //converting angle into pulse width value at 500-2480

Related product manuals