0% found this document useful (0 votes)
31 views

Chapter 5

The document discusses whiskers, which are normally open momentary switches, and how their pressed/not pressed states can be monitored with digital input pins on an Arduino. When a whisker is pressed, it pulls the input pin to 0 volts, so digitalRead returns 0. Nested if statements allow the code to evaluate multiple conditions and call different functions depending on the specific whisker states.

Uploaded by

api-357697027
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Chapter 5

The document discusses whiskers, which are normally open momentary switches, and how their pressed/not pressed states can be monitored with digital input pins on an Arduino. When a whisker is pressed, it pulls the input pin to 0 volts, so digitalRead returns 0. Nested if statements allow the code to evaluate multiple conditions and call different functions depending on the specific whisker states.

Uploaded by

api-357697027
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

1. What kind of electrical connection is a whisker?

A normally open, momentary, single-pole, single-throw tactile switch.

2. When a whisker is pressed, what voltage occurs at the I/O pin monitoring
it? What binary value will the digitalRead function return? If digital pin 8 is
used to monitor the whisker circuit, what value does digitalRead return when a
whisker is pressed, and what value does it return when a whisker is not pressed?

Zero (0) volts, resulting in binary zero (0) returned by digitalRead.

digitalRead(8) == 0 when whisker is pressed.

digitalRead(8) == 1 when whisker is not pressed.

3. If digitalRead(7)== 1, what does that mean? What does it mean if


digitalRead(7)== 0? How about digitalRead(5)== 1 and digitalRead(5)==
0?

digitalRead(7)== 1 means the right whisker is not pressed.


digitalRead(7)== 0 means the right whisker is pressed.
digitalRead(5)== 1 means the left whisker is not pressed.
digitalRead(5)== 0 means the left whisker is pressed.

4. What statements did this chapter use to call different navigation functions
based on whisker states?

This chapter used if, ifelse, and ifelse ifelse statements to evaluate whisker
conditions and call navigation functions.

5. What is the purpose of having nested if statements?

If one condition turns out to be true, the code might need to evaluate another condition with a
nested if statement.

You might also like