Close

PWM motor testing

A project log for Haptic Sleeve

Sleeve worn on the arm to provide haptic feedback while performing handwriting exercises.

grant-stankaitisGrant Stankaitis 03/29/2020 at 23:320 Comments

Today I worked on testing the PWM motor functionality of the system using the Sparkfun TB6612FNG motor drivers. As you can see in the picture below, I followed the schematic that the previous students used. To simplify things, I wrote out what the pins should be connected to.

Only one motor driver and one motor was connected for this test

Below is the code that I used to test the motor:

import time
import machine
from machine import Pin

motor = machine.PWM(Pin(18))
motor.freq(1000)

while True: # On for 2 seconds, off for 2 seconds
  motor.duty(341) # Input different values here to test
  time.sleep(2)
  motor.duty(0)
  time.sleep(2)

My next test will be to wire up all of the motors and expand my program to sequentially send a signal to each motor. 

Discussions