Working with sensors
Objectives
- Learn about selection
- Be able to read sensors
- Be able to respond to the brick buttons
- Work with text
- Send data from one block to another
- Learn about timing
Assignment
- Attach the following sensors. They only need to be connected via a wire to the brick. Later you will be mounting sensors.
- Touch sensor on port 1
- Ultrasonic sensor on port 2
- Color sensor on port 3
- Create a clean program to display each of the sensors as following:
- if the left button is pressed, display the status of the touch sensor
- if the middle button is pressed, display the value of the ultra sonic sensor
- if the right button is pressed, display the value of the color sensor
- if the top button is pressed, have the brick say something or make a sound
- make sure that the display can be easily read before the program ends
- Do not:
- use any repetition
- use any parallel programming
- Do not forget to:
- Include a comment block that indicates the names of the members of the team, which robot it as designed for, and the assignment
- Make the code look neat
Submission instructions
- Due date is found on Canvas
- Create a pdf document that contains the following information
- Your name
- A brief description of what you did
- How well you achieve each objective
- Create an empty zip folder
- place your code (making sure it has the comment required) in the folder
- place your pdf in the folder
- Submit the zip folder on Canvas
Hints
These hints are on separate pages. Do not look at them unless you are lost. You will not be penalized for using them but you should try things on your own first. Most of the hints from the first lab also still apply!
- Getting data from a sensor to a string
- Displaying the string on the brick
- Trouble seeing the string on the brick
Challenges
- Include the rotational sensor (for the bottom button) and describe how to use it is your writeup
- After the individual sensor is displayed and read, display all sensors with only one more block for displaying.