Question: 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
1298N chip.
The process of the washing machine goes as follows:
Washing motor to spin clockwise (cw) for 30 seconds
Washing motor to spin counterelockwise (ccw) for 20 seconds
Drying motor to spin clockwise (cw) for 40 seconds
Drying motor to spin counterclockwise (cew) for 25 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 motor(pin 1, pin2, enable pin, duration):
#fill the missing lines
while True:
run motor(washing cw pin, washing_ccw_pin, washing enable pin. 30)
#fill the missing lines
GPIO setmode GPIO. BeM)
washing ew pin wasting cow-pin =27
washing enable pin =24
deving ew-pin =22
drying cew pin 25
drying enable pin =2
# Set the pins as output
UPlO setup washing cw pin, GPio.oUl
GPlO.setupwashing cow-pin, GPlO.OUT
GPIO.setup/washingcnable_pin. GPlO.0UT)
GPlO.setup(drying cw_pin, GPIO.OUT)
GPlO.setup(drying cow. pin, GPIO.OUT)
GPIO setup(drying enable_pin, GPIO.OUT)
#INT
#IN2
#IN4
del run motor(pini, pinz, enable pin, duration):
#fill the missing lines
while True:
run_motor(washing_cw_pin. washing cow_pin, washing enable pin, 30)
#fill the missing lines
 Complete the below python code used to control both washing machine

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 Databases Questions!