Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Complete the below python code used to control both washing machine motors based on the above procos, noso your code well ontimized a ou can
Complete the below python code used to control both washing machine motors based on the above
procos, noso your code well ontimized a ou can t use the time sioset tunction.
import RPi.GPIO as GPIO
im port time II Question II
A washing machine consists of two motors, a motor to spin during the wash cycle and a second motor
to spin during the drying cycle. Both motors are to be controlled by a raspberty pi through a single
chip.
The process of the washing machine goes as follows:
Washing motor to spin clockwise for seconds
Washing motor to spin counterelockwise ccw for seconds
Drying motor to spin clockwise cw for seconds
Drying motor to spin counterclockwise cew for seconds
Complete the below python code used to control both washing machine motors based on the above
process. Keep vour code well optimized. You can't use the time.sleep function.
def run motorpin pin enable pin, duration:
#fill the missing lines
while True:
run motorwashing cw pin, washingccwpin, washing enable pin.
#fill the missing lines
GPIO setmode GPIO. BeM
washing ew pin wasting cowpin
washing enable pin
deving ewpin
drying cew pin
drying enable pin
# Set the pins as output
UPlO setup washing cw pin, GPio.oUl
GPlO.setupwashing cowpin, GPlO.OUT
GPIO.setupwashingcnablepin. GPlOUT
GPlO.setupdrying cwpin, GPIO.OUT
GPlO.setupdrying cow. pin, GPIO.OUT
GPIO setupdrying enablepin, GPIO.OUT
#INT
#IN
#IN
del run motorpini pinz, enable pin, duration:
#fill the missing lines
while True:
runmotorwashingcwpin. washing cowpin, washing enable pin,
#fill the missing lines
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started