Activity 6: Ultrasonic Sensor

Estimated completion time:

15-20 minutes

Electronic Systems: The Robot & The Codes (Page 79 & 80)

Exercise Hint #1

Setup the LED 3 first similarly like in Activity 1.


-Before void setup

-In void setup

-In void loop

Exercise Hint #2

In the end of void loop (but still in the void loop) add a If statement


Example:


If (distance<5) {

digitalWrite(LED3,HIGH);

}

else {

digitalWrite(LED3,LOW);

}


(P/S: This is not the full code)