Smaller screens (1100px<) might have website design issues.
We are using Serial Output with the robot. Why is this useful? How else could you test these sensors?
Using Serial Output with the robot is useful because it is a simple and easy-to-code method to debug. Specifically display values we want to see while the program is running, for a example a variable that could be the cause of a coding error. To test if the sensors are working, you can use anything to display if they are working, for example with LEDs that turn on when the whiskers come into contact with a wall.
In your own words, why is it important to test the hardware before writing more advanced code?
It is essential to test earlier code and the hardware because if there are bugs (even if they do not cause an error), that can compound the more code you write. It is better to deal with any bugs before hand than let it pile up with more advanced and longer code.
What do you believe the robot should do if it hits something with the left, right or both whiskers.
When writing my code for challenge two, I would check if either whisker comes into contact with the box. When writing escaping-corner-code, it is more important to determine which whisker(s) have come into contact but with challenge two it is not. When one of them touch, I do not care which, the code to go along the wall a bit (go backwards, rotate right, go straight, and rotate left) would run.
In your own words, explain how the whisker reads an input of HIGH or LOW.
The whisker sensors reads of HIGH or LOW (1 or 0, respectively) based on whether the circuit it is part of is open or closed. When the whisker is not touched, the circuit is open, and there is no path for a circuit (it's open, unconnected). The designated digital pin for the whisker reads HIGH (.digitalRead() == 1) because it is connected to the 5V pin (which cannot flow to the ground). When the whisker is touched, the circuit is closed/completed, allowing current to flow from the 5V pin, to the whisker, into the digital pin, and to the ground. The digital pin then detects a LOW signal (0V).
Also in your own words, why does the pin read a zero when the whisker is connected? You should refer to pull up resistors.
As mentioned above, when the whisker is not pressed, the digital pin is connected to the 5V (through a pull-up resistor), which keeps the pin at HIGH (even though no current is flowing). When the whisker is pressed, it connects the digital pin to the ground, providing an easier route for the electricity to flow to (not to the digital pin, which would read LOW). The pull-up resistor is just there to keep the pin HIGH when the whisker is not being pressed.
I did not do the corner escape code or challenge three.