keyestudio
www.keyestudio.com
digitalWrite(outputPin, LOW);
int Rdistance = pulseIn(inputPin, HIGH);
Rdistance= Rdistance/58; // Transform pulse time to distance
if(Mode==3){
lcd.setCursor(11, 1);
lcd.print("R= ");
lcd.setCursor(13, 1);
lcd.print(Rdistance,DEC);
Serial.print("\n R = ");
Serial.print(Rdistance,DEC);
return Rdistance;
}
else return Rdistance;
}
void setup()
{
pinMode(servopin,OUTPUT); //setting motor interface as output
LCD1602_init(); //initializing 1602
M_Control_IO_config(); //motor controlling the initialization of IO
Set_Speed(Lpwm_val,Rpwm_val); //setting initialized speed
Set_servopulse(DuoJiao); //setting initialized motor angle
pinMode(inputPin, INPUT); //starting receiving IR remote control signal
pinMode(outputPin, OUTPUT); //IO of ultrasonic module
Serial.begin(9600); //initialized serial port , using Bluetooth as serial port, setting baud
lcd.setCursor(0, 0); //setting cursor at 0.0