Close

PWM motor testing (all motors)

A project log for Haptic Sleeve

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

grant-stankaitisGrant Stankaitis 03/30/2020 at 00:170 Comments

After further testing, I can confirm that 2 motor drivers and all 4 motors work! See the video below to see all 4 motors vibrating sequentially.

Below is the code that I wrote to sequentially test all 4 motors:

import time
import machine
from machine import Pin

motor1 = machine.PWM(Pin(18))
motor2 = machine.PWM(Pin(19))
motor3 = machine.PWM(Pin(22))
motor4 = machine.PWM(Pin(23))

motor1.freq(1000)
motor2.freq(1000)
motor3.freq(1000)
motor4.freq(1000)

while True:
  motor1.duty(341) # Motor 1 on
  time.sleep(2)
  motor1.duty(0) # Motor 1 off
  time.sleep(2)
  motor2.duty(341) # Motor 2 on
  time.sleep(2)
  motor2.duty(0) # Motor 2 off
  time.sleep(2)
  motor3.duty(341) # Motor 3 on
  time.sleep(2)
  motor3.duty(0) # Motor 3 off
  time.sleep(2)
  motor4.duty(341) # Motor 4 on
  time.sleep(2)
  motor4.duty(0) # Motor 4 off
  time.sleep(2)

Now that I verified all 4 motors working, my next test will be sending messages via MQTT to the ESP32 to activate motors, simulating notifying the user of a deviation from the drawing path.

Discussions