Rescuer Learn 2: Installing the Distance Sensors
6. Sensor Testing - init
Let’s now write some code to test that our sensors work and learn how to use them.
To test the distance sensors, you will write some code to repeatedly take sensor readings for 30 seconds, reporting the values read as they happen.
Let’s record the start time of our program.
- Within the empty init() function in the Variable Initialization cell, declare a start_time variable.
- Assign the result of an initial time check to it.
- Let’s also declare and set up empty value lists ready for the left-facing and front-facing distance sensors to store their readings in. We will call these left_values and front_values.