Press enter after choosing selection

Exploring Motors

When

Thursday September 19, 2019: 6:30pm to 8:30pm  Add to Calendar /   Add to Google Calendar

Where

Downtown Library: Secret Lab

Description

Learn how motors work and how you can incorporate one in your next electronics project.

We will build a simple motor to understand the principles at work before hooking up a hobby motor in a guided project that we will control with code.

For those who missed the program but still want the Python code:

import RPi.GPIO as GPIO

from time import sleep

# Pins for Motor Driver Inputs
Motor1A = 24
Motor1B = 23
Motor1E = 25

def setup():
    GPIO.setmode(GPIO.BCM) # GPIO Numbering
    GPIO.setup(Motor1A,GPIO.OUT) # All pins as Outputs
    GPIO.setup(Motor1B,GPIO.OUT)
    GPIO.setup(Motor1E,GPIO.OUT)

def loop():
    # Going forwards
    GPIO.output(Motor1A,GPIO.HIGH)
    GPIO.output(Motor1B,GPIO.LOW)
    GPIO.output(Motor1E,GPIO.HIGH)
    sleep(5)
 
    # Going backwards
    GPIO.output(Motor1A,GPIO.LOW)
    GPIO.output(Motor1B,GPIO.HIGH)
    GPIO.output(Motor1E,GPIO.HIGH)
    sleep(5)
 
    # Stop GPIO.output(Motor1E,GPIO.LOW)

def destroy():
    GPIO.cleanup()

if __name__ == '__main__': # Program start from here
setup()
try:
    loop()
except KeyboardInterrupt:
    destroy()