Toy Car Phase 2

by dburger in Craft > Printmaking

15 Views, 0 Favorites, 0 Comments

Toy Car Phase 2

Screenshot (137).png

Python codes that

  1. makes a noise when either of the buttons are pressed
  2. Lights up red
  3. Spins
  4. Lights Up and Spins Simultaneously

Change- we tried to make it move forward last time but were unsuccessful. This time we are making the car spin since we have figured out on Python how to code spinning.

Our CPX device was coded through Python and through these codings I was able to make the CPX lights on the car light up red constantly. I also created a code where if you press a button it makes a noise just like if you press a button in the car it will make a noise. Lastly, there is a code that allows for the wheel to spin fully. This time we coded the car for the wheel to spin not for the car to mpve forward to ensure that our third code works as we were unsucessful to get it to move last time.


Supplies

CPX Image.jpg
  1. Adafruit Circuit Playground Express Basekit
  2. Continuous Rotation Micro Servo
  3. Alligator Clips to Male Wires
  4. 3D Printer
  5. Computer
  6. 3D printed car
  7. Wheels that can spin
  8. Python App
  9. Hot Glue

Instructions and Wiring

Screenshot (139).png
  1. Go to thingiverse and search toy car or use this link, https://www.thingiverse.com/thing:2741143 .
  2. Click the “Download All Files” button
  3. Open the .STL file in TinkerCAD
  4. Upload file to 3D printer
  5. The design doesn’t require supports to be printed
  6. Visit MakeCode for Adafruit
  7. Use code blocks to:
  8. On Start → Set Servo on A1 to 90°
  9. Input → On Button A Clicked → Set Servo on A1 to 0°
  10. Input → On Button B Clicked → Set Servo on A1 to 180°
  11. Connect your Circuit Playground Express (CPX) via USB
  12. Click “Download” in MakeCode, drag the .uf2 file to the CPX drive
  13. Done! The servo now responds to button presses
  14. Python code: # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries

# SPDX-License-Identifier: MIT

"""This example lights up all the NeoPixel LEDs red."""

from adafruit_circuitplayground import cp

import time

import board

import pwmio

from adafruit_motor import servo

# create a PWMOut object on Pin A2.

pwm = pwmio.PWMOut(board.A2, duty_cycle=2 ** 15, frequency=50)

my_servo = servo.Servo(pwm)

cp.pixels.brightness = 0.3

cp.pixels.fill((0, 0, 0)) # Turn off the NeoPixels if they're on!

while True:

cp.pixels.fill((50, 0, 0))

if cp.button_a:

cp.play_file("examples_dip.wav")

cp.pixels[2] = (0, 255, 0)

for angle in range(0, 180, 5): # 0 - 180 degrees, 5 degrees at a time.

my_servo.angle = angle

time.sleep(0.05)

else:

cp.pixels[2] = (0, 0, 0)

if cp.button_b:

cp.play_file("examples_dip.wav")

cp.pixels[7] = (0, 0, 255)

for angle in range(180, 0, -5): # 180 - 0 degrees, 5 degrees at a time.

my_servo.angle = angle

time.sleep(0.05)

else:

cp.pixels[7] = (0, 0, 0)

Insert servo motor into the slot

Secure with hot glue

Plug the servo wire into:

Orange → A1

Red → VOUT

Brown → GND

  1. Attach wheels to axles
  2. Mount CPX onto chassis with tape or screws
  3. Plug in battery pack or use USB for power
  4. Press A/B to move the servo and control the car


Printing Example

Screenshot (140).png
  1. Download and print the following STL files using a 3D printer. Use a raft and supports.
  2. These files were designed using TinkerCAD and
  3. Mount remixed from Adafruit’s Snap-fit Mount

Car:

https://www.tinkercad.com/things/cQewQv7MkkP-fabulous-waasa-gaaris?sharecode=rO93i3UCoz1eH-_KD66ip5Ptdy0Uf_-UhbCihgTcHgI

Wheels and Rod: https://www.tinkercad.com/things/lIKVlscdAAl-spectacular-jaban?sharecode=uOAImMB7Q6ergd-J9_GlXFvjagYFXy-yAnGl_VzKAo4

Use these links and download them as STL documents. After downloading open Maker Bot. Then import the car document and make sure the printer type is set to sketch. When ready to print, export the document so it is able to convert to a makerbot document. Then do the same with the wheel and rod document to convert it into a makerbot document.