Keyestudio Ks0428 Manual page 177

Table of Contents

Advertisement

www.keyestudio.com
pinMode(Trig, OUTPUT);
pinMode(Echo, INPUT);
pinMode(ML_Ctrl, OUTPUT);
pinMode(ML_PWM, OUTPUT);
pinMode(MR_Ctrl, OUTPUT);
pinMode(MR_PWM, OUTPUT);
}
void loop(){
random2 = random(1, 100);
a = checkdistance();
ultrasonic sensor to variable a
if (a < 20) //when the front distance detected is less than 20
{
Car_Stop(); //robot stops
delay(500); //delay in 500ms
procedure(160); //Ultrasonic platform turns left
for (int j = 1; j <= 10; j = j + (1)) { //for statement, the data will
be more accurate if ultrasonic sensor detect a few times.
a1 = checkdistance();
by ultrasonic sensor to variable a1
}
delay(300);
//assign the front distance detected by
//assign the left distance detected
177

Advertisement

Table of Contents
loading

Table of Contents