Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import RPi.GPIO as GPIO from time import sleep GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) class Motor: def __init__(self, EnaA, In1A, In2A, EnaB, In1B, In2B): self.EnaA = EnaA self.In1A =

import RPi.GPIO as GPIO from time import sleep GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) class Motor: def __init__(self, EnaA, In1A, In2A, EnaB, In1B, In2B): self.EnaA = EnaA self.In1A = In1A self.In2A = In2A self.EnaB = EnaB self.In1B = In1B self.In2B = In2B GPIO.setup(self.EnaA, GPIO.OUT) GPIO.setup(self.In1A, GPIO.OUT) GPIO.setup(self.In2A, GPIO.OUT) GPIO.setup(self.EnaB, GPIO.OUT) GPIO.setup(self.In1B, GPIO.OUT) GPIO.setup(self.In2B, GPIO.OUT) self.pwmA = GPIO.PWM(self.EnaA,100) self.pwmA.start(0) self.pwmB = GPIO.PWM(self.EnaB,100) self.pwmB.start(0) def move(self, motorA, motorB): GPIO.output(self.In1A, GPIO.LOW) GPIO.output(self.In2A, GPIO.HIGH) GPIO.output(self.In1B, GPIO.LOW) GPIO.output(self.In2B, GPIO.HIGH) self.pwmA.ChangeDutyCycle(motorA) self.pwmB.ChangeDutyCycle(motorB) def start(self, s): for i in range(0, s): i = i + 1 sleep(0.01) self.pwmA.ChangeDutyCycle(i) self.pwmB.ChangeDutyCycle(i) return def stop(self, s=0): self.pwmA.ChangeDutyCycle(s) self.pwmB.ChangeDutyCycle(s) def motormain(self, speed, diva, angl): Motor.move(True,speed-angl+diva//10,speed+angl-diva//10) return if __name__ == '__main__': motor = Motor(20, 25, 8, 7, 1, 21) motor.motormain(70,100,40) 

############################################

I get an error while executing the code:

Traceback (most recent call last): File "/home/pi/tmp/402V1.0/tmp/pycharm_project_34/Motor.py", line 51, in motor.motormain(70,100,40) File "/home/pi/tmp/402V1.0/tmp/pycharm_project_34/Motor.py", line 46, in motormain Motor.move(True,speed-angl+diva//10,speed+angl-diva//10) TypeError: unbound method move() must be called with Motor instance as first argument (got bool instance instead)

Process finished with exit code 1

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

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago