Question: 4 . 1 Understanding Code All code should be pseudo code and submitted before the lab. Code should be written and submitted as a .

4.1 Understanding Code
All code should be pseudo code and submitted before the lab. Code should be written and
submitted as a .txt file. Grades will be given to the structure of code, rather than if it is
functioning. In other words, it is more important that you figure out how the code should be
written, rather than the position of every colon or bracket.
1. Prepare the code that will determine if the limit switch is pressed or not. The switch
is normally open and connected to pin 20
2. The code provided for this lab introduces the use of object-oriented programming
with Python. This essentially means that when you run the code, it creates objects (in
Python they are called classes) and calls methods from those classes to perform the
desired actions. Using the provided code as your guide, go back and create a Motor
object that uses the code you wrote in the first lab. More information about the OOP
can be found in the lectures or here.
3. The DistanceSensor.py library provides a simple implementation of the ultrasonic
sensor. Rather than use that library, look online and see if you can find a way to
calculate the distance without using the DistanceSensor.py library. Hint: you will
need to use both the ECHO and TRIGGER pin, as well as know the speed of sound.
4.2 Understanding Circuitry
1. The LCD is controlled by I2C, but does not need to be. Using the component data
sheet, create a circuit diagram that uses GPIO pins rather than I2C.
4.3 Understanding Mechanical Systems
1. If your ultrasonic sensor measures a time of 0.03 microseconds, how far away is the
object?
2. The rotary encoder has an output shaft that is 4.5mm in diameter and is directly
connected to the wheel which has a diameter of 6cm. If the rotary encoder has 30
positions per revolution, how far does the robot travel per increment?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!