I just don't know how to describe this. It was working, but then I changed the value of distance = duration*0.034/2;
. I then changed it back but it still gave me these errors. Is it the Arduino? (Bluno nano) Is it the code?
const int trigPin = 9;
const int echoPin = 10;
int duration;
int distance;
void setup(){
Serial.begin(9600);
pinMode(echoPin, INPUT);
pinMode(trigPin, OUTPUT);
}
void loop(){
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration*0.034/2;
Serial.print("Distance: " + distance);
delay(500);
}