Chapter 5 Challenges
Projects
- Modify RoamingWithWhiskers so that the BOE Shield-Bot stops and makes a 4 kHz beep that lasts 100 ms before executing its usual evasive maneuver. Make it beep twice if both whisker contacts are detected during the same sample. HINT: Use the pause function you developed in the Exercises section to make it pause immediately after the tone starts playing. Also, a 0.2 second pause after the tone call separates the 0.1 second tone from servo motion, or allows you to hear a second tone.
- Modify RoamingWithWhiskers so that the BOE Shield-Bot roams in a 1 yard (or 1 meter) diameter circle. When you touch one whisker, it will cause the BOE Shield-Bot to travel in a tighter circle (smaller diameter). When you touch the other whisker, it will cause the BOE Shield-Bot to navigate in a wider diameter circle.
- What kind of electrical connection is a whisker?
- 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?
- 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?
- What statements did this chapter use to call different navigation functions based on whisker states?
- What is the purpose of having nested if statements?
Projects
- Modify RoamingWithWhiskers so that the BOE Shield-Bot stops and makes a 4 kHz beep that lasts 100 ms before executing its usual evasive maneuver. Make it beep twice if both whisker contacts are detected during the same sample. HINT: Use the pause function you developed in the Exercises section to make it pause immediately after the tone starts playing. Also, a 0.2 second pause after the tone call separates the 0.1 second tone from servo motion, or allows you to hear a second tone.
- Modify RoamingWithWhiskers so that the BOE Shield-Bot roams in a 1 yard (or 1 meter) diameter circle. When you touch one whisker, it will cause the BOE Shield-Bot to travel in a tighter circle (smaller diameter). When you touch the other whisker, it will cause the BOE Shield-Bot to navigate in a wider diameter circle.
- Write a routine that uses a single variable named whiskers to track whisker contacts. It should store a 3 when no whiskers are contacted, a 2 if the right whisker is contacted, a 1 if the left whisker is contacted, or 0 if both whiskers are contacted. Hint: multiply the result by two.
- Modify the loop function in RoamingWithWhiskers so that it makes the BOE Shield-Bot stop and not restart when both whiskers contact at the same time.
- Add a function named pause to RoamingWithWhiskers. It should make the BOE Shield-Bot stay still for a certain amount of time.
- Modify the loop function so that the BOE Shield-Bot stays still for 0.5 seconds before backing up and turning.
Projects
- Modify RoamingWithWhiskers so that the BOE Shield-Bot stops and makes a 4 kHz beep that lasts 100 ms before executing its usual evasive maneuver. Make it beep twice if both whisker contacts are detected during the same sample. HINT: Use the pause function you developed in the Exercises section to make it pause immediately after the tone starts playing. Also, a 0.2 second pause after the tone call separates the 0.1 second tone from servo motion, or allows you to hear a second tone.
- Modify RoamingWithWhiskers so that the BOE Shield-Bot roams in a 1 yard (or 1 meter) diameter circle. When you touch one whisker, it will cause the BOE Shield-Bot to travel in a tighter circle (smaller diameter). When you touch the other whisker, it will cause the BOE Shield-Bot to navigate in a wider diameter circle.
- Modify RoamingWithWhiskers so that the BOE Shield-Bot stops and makes a 4 kHz beep that lasts 100 ms before executing its usual evasive maneuver. Make it beep twice if both whisker contacts are detected during the same sample. HINT: Use the pause function you developed in the Exercises section to make it pause immediately after the tone starts playing. Also, a 0.2 second pause after the tone call separates the 0.1 second tone from servo motion, or allows you to hear a second tone.
- Modify RoamingWithWhiskers so that the BOE Shield-Bot roams in a 1 yard (or 1 meter) diameter circle. When you touch one whisker, it will cause the BOE Shield-Bot to travel in a tighter circle (smaller diameter). When you touch the other whisker, it will cause the BOE Shield-Bot to navigate in a wider diameter circle.