We were tasked to create a robot lantern for the lantern parade or festival that is hosted at our school. These robots had to successfully traverse the paths set in our classroom and had to successfully complete three races on the day of the lantern parade.
For our robot we had to make sure that the wight was balanced and did not wobble or slip. We had to use Bluetooth controls and had to also have a Neo pixel strip that worked with Bluetooth controls as well. At least the side of our robot had to be digitally fabricated in Onshape a CAD tool that we use often in class. Finger joints should've been included. We also had to make sure that we followed our design plan. Our final robot had to look like our sketch.
Unfortunately I was not able to get a video of my robot traversing the yellow path because I fell behind. I programmed using Bluetooth and continued to use Bluetooth for the rest of the testing.
In this phase of the project we moved all code from the computer to the Pico to a Bluetooth module. We created function codes that we saved to our Pico. In the code there was a new file that we had to include. We had to download the dabble file to the library folder for the Pico. Then we were able to add our Bluetooth module to our robots. When the functions were coded and defined we were able to test Bluetooth control once we saved code.
In Thonny, a application that we used to code our robot, we had to learn how to create and define functions. To do so we had to use the autonomous code and instead of using the time sleep and variables we used def___(). The parenthesis are to make sure that the code is fully defined. Once we defined code we were able to place codes in command buttons. The autonomous code was created by using what we knew about how the servos move to create this code.
"""CircuitPython Example of how to read data from the Dabble app"""
import binascii
import board
import busio
import digitalio
import time
from dabble import Dabble
dabble = Dabble(board.GP4, board.GP5, debug=True)
"""CircuitPython Essentials Servo standard servo example"""
import time
import board
import pwmio
from adafruit_motor import servo
# create a PWMOut object on Pin A2.
pwm = pwmio.PWMOut(board.GP17, duty_cycle=2 ** 15, frequency=50)
pwm2 = pwmio.PWMOut(board.GP27, duty_cycle=2 ** 15, frequency=50)
# Create a servo object, my_servo.
left_servo = servo.Servo(pwm)
right_servo = servo.Servo(pwm2)
def forward():
left_servo.angle = 180
right_servo.angle = 0
def stop():
left_servo.angle = 90
right_servo.angle = 90
def left():
left_servo.angle = 90
right_servo.angle = 0
def backwards():
right_servo.angle = 0
left_servo.angle = 180
def right():
left_servo.angle = 90
right_servo.angle = 180
"""Programming a Neopixel strip using CircuitPython"""
import time
import board
from rainbowio import colorwheel
import neopixel
pixel_pin = board.GP2
num_pixels = 10
pixels = neopixel.NeoPixel(pixel_pin, num_pixels, brightness=.2, auto_write=False)
def color_chase(color, wait):
for i in range(num_pixels):
pixels[i] = color
time.sleep(wait)
pixels.show()
time.sleep(0.5)
def rainbow_cycle(wait):
for j in range(255):
for i in range(num_pixels):
rc_index = (i * 256 // num_pixels) + j
pixels[i] = colorwheel(rc_index & 255)
pixels.show()
time.sleep(wait)
RED = (255, 0, 0)
YELLOW = (255, 150, 0)
GREEN = (0, 255, 0)
CYAN = (0, 255, 255)
BLUE = (0, 0, 255)
PURPLE = (180, 0, 255)
while True:
message = dabble.read_message()
if (message != None): # if there is a message
print("Message: " + str(message))
# Implement tank steering on a 2 wheeled robot
if (message.up_arrow_pressed):
print("Move both motors forward")
forward()
elif (message.down_arrow_pressed):
print("Move both motors backward")
backwards()
elif (message.right_arrow_pressed):
print("Move left motor forward and right motor backward")
righ ()
elif (message.left_arrow_pressed):
print("Move left motor backward and right motor forward")
left()
elif (message.no_direction_pressed):
print("Stop both motors")
else:
print("Something crazy happened with direction!")
if (message.triangle_pressed):
print("Raise arm")
RED()
elif (message.circle_pressed):
print("Lower arm")
PURPLE()
elif (message.square_pressed):
print("Squirt water")
CYAN()
elif (message.circle_pressed):
print("Fire laser")
elif (message.start_pressed):
print("Turn on LED")
elif (message.select_pressed):
print("Do victory dance")
stop()
elif (message.no_action_pressed):
print("No action")
else:
print("Something crazy happened with action!")
For the front and back of my carriage, I used the center point rectangle tool to create a rectangle of my preferred size. I used the dimension tool to make sure that it was 4.5" x 6". Once I dimensioned it from the corners on both the side and bottom i used the line tool to mark where I wanted my tapered edges to be. I then use the cut tool to take off the corners of the rectangle giving me this somewhat octagon shape.
I used the rectangle tool to create the sides to enclose my electronics and to add the sides to my carriage. I dimensioned the sides of my carriage accordingly. However all I did for all sides of my robot I used the rectangle tool.
This is a video of my robot successfully traversing the purple path. I wasn't able to get video of my robot on race day, but I was able to record my robot on the purple path with my final design.
This is an accurate illustration of what our circuit looks like. The Pico is the power source and the bread board helps power all the other component. This includes the servos and how they are wired, the neo pixel strip, the Bluetooth module, and the battery packs. GND helps close the circuits and send signals to the component and VSYS powers the components.
This project was very interesting to say the least. There were lots of ups and downs but I do feel that overall I did learn a lot about the engineering process and troubleshooting. The robot project started with us getting an understanding of how a full circuit works. I felt like that was incredibly helpful when dealing with challenges regarding our breadboards. The amount of hardware and software challenges I faced throughout this project however, was quite discouraging in the beginning. The integration of code was easy at first. I got all of my function code, neo-pixel code was implemented and saved, and I had all libraries saved. My Pico then decided it was not going to work so i had to change Picos, recode and resave everything. When creating my prototype we started to run into a cardboard shortage. There were not enough large pieces of cardboard. Everyone had to use scraps and that's a lot of people. There was also time management issues for me personally. I was able to go to makerspace and get a few things done early in the morning. There were also a few issues I encountered when wiring. I shorted my batteries because I put a red wire in the black row. I fixed that by rewiring my batteries. I also removed the solder, so I had to get assistance to fix it. Overall I had an experience doing this project. Was it good? I don't know, it wasn't bad. I learned a lot. I really did enjoy the robot races though. There were a lot of unique things to see at the lantern parade I really had fun.