hi there is a simple code of arduino C language ,and i am not able to resolve this issue ,i have this error in last 7 line of the code which is the line no:307 ,please tell me how can i resolve this issue
long duration, distance;
String dist;
digitalWrite(trigPin, LOW); // Added this line
delay(50); // Added this line
digitalWrite(trigPin, HIGH);
// delayMicroseconds(1000); - Removed this line
delay(50); // Added this line
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
if (distance < 1) { // This is where the LED On/Off happens
Serial.print(distance);
//for 2 proximity
long secondduration, seconddistance;
String seconddist;
digitalWrite(trig1Pin, LOW); // Added this line
delay(50); // Added this line
digitalWrite(trig1Pin, HIGH);
// delayMicroseconds(1000); - Removed this line
delay(50); // Added this line
digitalWrite(trig1Pin, LOW);
secondduration = pulseIn(echo1Pin, HIGH);
seconddistance = (secondduration/2) / 29.1;
if (seconddistance < 1)
{ // This is where the LED On/Off happens
Serial.print(seconddistance);
}
seconddist = String(seconddistance);
if (seconddistance >= 50 || seconddistance <= 0)
{
// Serial.println("Out of range");
seconddist = "Out of range";
}
else {
Serial.print(seconddistance);
Serial.println(" cm");
}
delay(1000);
// HC12.print(String(distance) + "\n");
//htjghjghdjdtgje
//for 2 prximity
seconddist = String(seconddistance);
if (seconddistance >= 50 || seconddistance <= 0)
{
// Serial.println("Out of range");
seconddist = "Out of range";
}
else {
Serial.print(seconddistance);
Serial.println(" cm");
}
delay(1000);
// HC12.print(String(distance) + "\n");
float flat, flon;
unsigned long age;
int heat =0;
gps.f_get_position(&flat, &flon, &age);
/***************/
HC12.print("LAT="+String(flat,6) +" | LONG=" + String(flon,6) + ", " "| Detected cm=" + String(dist)+ ", " "| TEMP[°C]="+ String(temp) + ", " "| Humidity[%]=" + String(humidity) + ", " "| Pressure[hPa]=" + String(pres) +", " "| Altitude[m]="+ String(alti) + String(dist)+ "\n"); // Transmit non-command message
/***************/
smartdelay(1000);
}
static void smartdelay(unsigned long ms)
{
unsigned long start = millis();
do
{
while (ss.available())
gps.encode(ss.read());
} while (millis() - start < ms);
}