#๐Ÿ”’ LEGO Spike Problem

6 messages ยท Page 1 of 1 (latest)

rare flume
#

Iโ€™m trying to add another motor to the basic drive base and add buttons to the remote. However, Iโ€™m trying to use degrees rather than continuous rotation as the attachment (forklift) can only move 45 degrees or less (to go up ). Also, Iโ€™m adding another button to the remote to make the attachment move down again (-45 degrees). The current software update will not allow these additions and cause the remote to not connect with the robot. If you need anything else besides what I have stated please lmk. Any help is greatly appreciated! Thank you:)
Code:

Define objects for a simple two motor rover using a DriveBase

hub = PrimeHub()
left_motor = Motor(Port.A, positive_direction=Direction.COUNTERCLOCKWISE)
right_motor = Motor(Port.E, positive_direction=Direction.CLOCKWISE)
drive_base = DriveBase(left_motor, right_motor, wheel_diameter=56, axle_track=96)

Speeds and accelerations to use

STRAIGHT_SPEED = 700 # straight driving speed (mm/sec)
TURN_RATE = 150 # turning rate (deg/sec)

Connect to the remote

hub.light.on(Color.YELLOW) # turn hub light yellow while trying to connect
rc = Remote() # will stop the program if it can't connect

Set status light on both hub and remote to green to indicate connection

hub.light.on(Color.GREEN)
rc.light.on(Color.GREEN)

The main loop repeatedly tests the remote buttons and reacts

while True:
# Get the set of buttons that are currently pressed,
pressed = rc.buttons.pressed()

# Determine what straight driving speed to use
if (Button.LEFT_PLUS in pressed):
    speed = STRAIGHT_SPEED
elif (Button.LEFT_MINUS in pressed):
    speed = -STRAIGHT_SPEED
else:
    speed = 0

# Determine what turn rate to use
if (Button.RIGHT_PLUS in pressed):
    turn_rate = TURN_RATE
elif (Button.RIGHT_MINUS in pressed):
    turn_rate = -TURN_RATE
else:
    turn_rate = 0

# Update the driving and turning speeds
drive_base.drive(speed, turn_rate)
stray trailBOT
#

@rare flume

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

small forge
#

!code

stray trailBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

stray trailBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.