Description: In this project, I created a robot that is capable of moving on wheels & lighting up. The goal of this project was to create a unique & aesthetically pleasing robot with lights that could move across multiple paths. Some constraints that I had to deal with were related to the material used for the project, including the dimensions of the robot & type of material I was able to use. Objectives of the project were as follows:
No slipping
Weight is balanced & stable
Programmed to traverse the long purple path
Easy access to the components
One LED on the outside of the robot
Brief & Digital Notebook
Phase 1: Autonomous Prototype
In this part of the project, I created my prototype, which was supposed to be coded to traverse an autonomous path. The prototype was required to move through code from Python, to be balanced with a caster wheel, & to be powered with battery power. Here is a video of my final result:
Phase 2: Bluetooth Control & Final Prototype
After my autonomous prototype, it was time to integrate Bluetooth into my robot. In this phase of the project, I was supposed to integrate a Bluetooth module into my code & circuit board & then code the robot to follow a lengthy purple path. Here is a video of my final result:
My Python Coding
While creating my robot, I also had to code the software, which includes the functions & movements that make my robot light up & move. In my final code, I have both Neo-pixel & servo functions, code libraries, variables, & etc. In yellow at the top of the code are the library data structures that are filled with hundreds of lines of code. These libraries are the basis of the code used throughout my document. This includes libraries of code for time, for servo speed, for Neo-pixel brightness, for Bluetooth, & etc. After the libraries, in green are the lines of code that define the pin location of hardware on the breadboard, where the hardware of my project receives its code. This includes the breadboard location of my right & left servos, my Bluetooth module (Dabble), & my Neo-pixel. Next, in red are the variables that represent either a piece of hardware or one of the colors for the Neo-pixel to show. The colors are set in an RGB color model format. In blue are the function data structures for my servos & Neo-pixel. There are Neo-pixel functions, such as theater chase, where it appears that two colors chase one another along the Neo-pixel; also, there are servo functions, which include directions such as forward, backward, left, right, & stop. Lastly, in orange at the bottom of my code are the command control structures. This includes the direction commands (forward, backward, left, right, & stop) & the Neo-pixel commands
# Simple code to read a message from the Dabble App over the DSDTech HM-10 bluetooth module
# Author: Eric Z. Ayers <ericzundel@gmail.com>
"""CircuitPython Example of how to read data from the Dabble app"""
import binascii
import busio
import digitalio
import time
import board
import pwmio
from adafruit_motor import servo
from dabble import Dabble
from rainbowio import colorwheel
import neopixel
# create a PWMOut object on Pin A2.
pwm = pwmio.PWMOut(board.GP22, duty_cycle=2 ** 15, frequency=50)
pwm1 = pwmio.PWMOut(board.GP3, duty_cycle=2 ** 15, frequency=50)
pixel_pin = board.GP2
dabble = Dabble(board.GP0, board.GP1, debug=True)
num_pixels = 10
# Create a servo & neopixel as variables.
my_servoright = servo.Servo(pwm)
my_servoleft = servo.Servo(pwm1)
pixels = neopixel.NeoPixel(pixel_pin, num_pixels, brightness=0.3, auto_write=False)
# Create colors for the neopixel as variables.
RED = (255, 0, 0) # 100% red, 0% green, 0% blue
GREEN = ( 0, 255, 0) # 0% red, 100% green, 0% blue
BLUE = ( 0, 0, 255) # 100% blue
CYAN = ( 0, 255, 255) # 0% red, 100% green, 100% blue
YELLOW = (255, 150, 0) # 100% red, 55% green, 0% blue
WHITE = (100, 100, 100) # 100% of all colors
BLACK = ( 0, 0, 0) # 0% of all colors (turns the LED off)
# Create functions for your servos & neopixels
def forward():
my_servoright.angle = 0
my_servoleft.angle = 180
def backward():
my_servoright.angle = 180
my_servoleft.angle = 0
def right():
my_servoright.angle = 180
my_servoleft.angle = 180
def left():
my_servoright.angle = 0
my_servoleft.angle = 0
def stop():
my_servoright.angle = 90
my_servoleft.angle = 90
def theater_chase2(color1, color2, wait):
for j in range(10): #do 10 cycles of chasing
for q in range(3):
for i in range(0, len(pixels)-1, 3):
pixels[i+q] = color1
pixels[i+q+1] = color2
pixels.show()
time.sleep(wait);
for i in range(0, len(pixels)-1, 3):
pixels[i+q] = BLACK
# Commands for code
while True:
message = dabble.read_message()
if (message != None):
print("Message: " + str(message))
# Implement tank steering on a 2 wheeled robot & control the color & pattern of the neopixel
if (message.up_arrow_pressed):
forward()
pixels.fill(BLUE)
pixels.show()
print("Move both motors forward")
elif (message.down_arrow_pressed):
backward()
pixels.fill(RED)
pixels.show()
print("Move both motors backward")
elif (message.right_arrow_pressed):
right()
pixels.fill(GREEN)
pixels.show()
print("Move left motor forward and right motor backward")
elif (message.left_arrow_pressed):
left()
pixels.fill(GREEN)
pixels.show()
print("Move left motor backward and right motor forward")
elif (message.no_direction_pressed):
stop()
pixels.fill(WHITE)
pixels.show()
print("Stop both motors")
else:
print("Something crazy happened with direction!")
if (message.triangle_pressed):
print("Theater Chase")
theater_chase2(BLUE, RED, 0.15)
pixels.show()
elif (message.circle_pressed):
print("No action")
elif (message.square_pressed):
print("No action")
elif (message.circle_pressed):
print("No action")
elif (message.start_pressed):
print("No action")
elif (message.select_pressed):
print("No action")
elif (message.no_action_pressed):
print("No action")
else:
print("Something crazy happened with action!")
Designs in Onshape
While I coded the software of my project, I also digitally fabricated the hardware of my project through the Onshape & Glowforge applications. Here are a few select tools I used to create parts of my final robot:
Caster Wheel
Revolve tool on the caster wheel
In Onshape, I used the Revolve tool on a key component of my robot, the caster wheel, to enhance stability. The revolve tool creates a 3-D shape by revolving the original sketch around a line in the center of the 3-D shape. This creates a cradle for a metal marble to latch on, roll in any direction, & give stability to my robot.
Extrude tool on the servo mount
In Onshape, I used the Extrude tool on another key component of my robot, the servo mount, to create control over my servos. The extrude tool creates a 3-D shape by expanding upon the 2-D sketch. The servo mount was very useful in creating a place to hold my servos.
Servo Mount
Top of the Robot
Mirror tool on the caster wheel
Lastly, in Onshape, I used the Mirror tool on another key component of my robot, the top of my robot, to hide electrical components & create an access panel to the components. The mirror tool copies a side of the top, which was finger-jointed, to create the same shape & design on the opposite side across a center line. This creates the top of my robot, which creates the cover for my robot's electrical components.
Final Circuit Diagram
Next, I created a digital model of how the electrical components work on my robot. In my robot, two 5-volt batteries provide direct power to my Raspberry Pi Pico, with positive power connecting to VSYS through the red wires & negative power connecting to GND through the black wires. Also, on the negative GND wires is the switch that controls the flow of power to the Pico. When the switch is on, a circuit of power is sent throughout the Pico to components such as the servos & Neo-pixel, which are connected to individual pins as well as GND & VSYS.
The Final Robot
Finally, after Bluetooth Coding, the Autonomous Prototype, Onshape, I was on to my Final Robot. Here are a couple of photos & videos showing off the capabilities & aesthetics of my final robot:
My Reflection
At the end of my project, I answered a couple of reflection questions:
How does my robot look compared to my concept?
My robot became completely different from my concept. While I still have the wings & curved front of my spaceship, I expected to have a tailfin & rockets hanging off the side.
What challenges did you face?
I faced a multitude of challenges when creating my robot.