Answered step by step
Verified Expert Solution
Link Copied!

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
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
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Server T-SQL Recipes

Authors: David Dye, Jason Brimhall

4th Edition

1484200616, 9781484200612

More Books

Students also viewed these Databases questions

Question

=+What conclusions about the additive and car types do you draw?

Answered: 1 week ago

Question

Identify global safety and health issues.

Answered: 1 week ago

Question

Discuss health care in the global environment.

Answered: 1 week ago