Keyestudio 4WD Bluetooth Multi-functional Car Manual page 107

Hide thumbs Also See for 4WD Bluetooth Multi-functional Car:
Table of Contents

Advertisement

Sample Code:
******************************************************************************
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
//////////////////////////////////////////////////
int inputPin=A0; // ultrasonic module
int outputPin=A1; // ultrasonic module TRIG to A1
LiquidCrystal_I2C lcd(0x27,16,2);
#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
keyestudio
//including libraries of I2C-LCD1602 liquid crystal
//including libraries of I2C
ECHO to A0
//defining liquid crystal
www.keyestudio.com
105

Advertisement

Table of Contents
loading

Related Products for Keyestudio 4WD Bluetooth Multi-functional Car

Table of Contents