user81242: what we're required to do on exam 
You don't have to completely give me the answers, I just started learning this yesterday so I'm pressured on learning it properly + the exam, thx

user7508: As written, the exam does not look like you are expected to build
something functional. Rather, that you must show that you understand how
to drive LEDs and a buzzer, how to write conditional code, etc. I would
suggest using a pot to simulate a distance reading, and writing
something along these lines:
void loop() {
    // Simulate a distance reading between 0 and 4 meters.
    float distance = analogRead(A0) * (4.0/1023);

    // React to the sensor reading.
    if (distance < 3) {
        // ...
    }
    // etc.
}


81242: <p>what we're required to do on exam <a href="https://i.stack.imgur.com/ADTxB.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ADTxB.jpg" alt="enter image description here" /></a></p>
<p>You don't have to completely give me the answers, I just started learning this yesterday so I'm pressured on learning it properly + the exam, thx</p>
 7508: <p>As written, the exam does not look like you are expected to build
something functional. Rather, that you must show that you understand how
to drive LEDs and a buzzer, how to write conditional code, etc. I would
suggest using a pot to simulate a distance reading, and writing
something along these lines:</p>
<pre class="lang-cpp prettyprint-override"><code>void loop() {
    // Simulate a distance reading between 0 and 4 meters.
    float distance = analogRead(A0) * (4.0/1023);

    // React to the sensor reading.
    if (distance &lt; 3) {
        // ...
    }
    // etc.
}
</code></pre>
