Mattyhawk
Posts: 10
Joined: Tue Nov 20, 2018 8:28 pm

Cam Jam Edukit 3

Sun Feb 10, 2019 12:27 pm

I was coding 7-pwm.py
Then I ran the code but it came up with this error:

"Traceback (most recent call last):
File "/home/pi/Edukit3/CamJam Edukit 3 - GPIO Zero/Code/7-pwm.py",
line 17, in <module>
robot.value = motorforward
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 299,
in __setattr__
return super(CompositeDevice, self).__setattr__(name, value)
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 146,
in __setattr__
return super(GPIOBase, self).__setattr__(name, value)
AttributeError: can't set attribute"


Can you help me fix it?

ps. this is the code that I am using:

"# CamJam EduKit 3 - Robotics

# Worksheet 7 - Controlling the motors with PWM


import time # Import the Time library

from gpiozero import CamJamKitRobot # Import the GPIO Zero Library CamJam library


robot = CamJamKitRobot()


# Set the relative speeds of the two motors, between 0.0 and 1.0

motorspeed = 0.5


motorforward = (motorspeed, motorspeed)

motorbackward = (-motorspeed, -motorspeed)

motorleft = (motorspeed, 0)

motorright = (0, motorspeed)


robot.value = motorforward

time.sleep(1)


robot.value = motorbackward

time.sleep(1) # Pause for 1 second


robot.value = motorleft

time.sleep(1) # Pause for 1 second


robot.value = motorright

time.sleep(1) # Pause for 1 second



robot.stop()"

Return to “Automation, sensing and robotics”