Maker HAT Base, allows you to easily access the Raspberry Pi 400 GPIO pins

Introduction

It is a bit difficult to access the GPIO pin on the Raspberry Pi 400. By using Maker HAT Base, we can easily make the wiring connections. For this video I will try to do a simple testing, controlling the stepper motor.

Video

Hardware Preparation

This is the list of items used in the video.

Sample Program

This is a python sample program to control stepper motor rotation based on 3 styles (single, double and interleave). Please install following libraries:

# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
# Use this example for digital pin control of an H-bridge driver
# like a DRV8833, TB6612 or L298N.
import time
import board
import digitalio
from adafruit_motor import stepper
DELAY = 0.01
STEPS = 200
# You can use any available GPIO pin on both a microcontroller and a Raspberry Pi.
# The following pins are simply a suggestion. If you use different pins, update
# the following code to use your chosen pins.
# To use with a Raspberry Pi:
coils = (
digitalio.DigitalInOut(board.D18), # A1
digitalio.DigitalInOut(board.D17), # A2
digitalio.DigitalInOut(board.D27), # B1
digitalio.DigitalInOut(board.D22), # B2
)
for coil in coils:
coil.direction = digitalio.Direction.OUTPUT
motor = stepper.StepperMotor(coils[0], coils[1], coils[2], coils[3], microsteps=None)
for step in range(STEPS):
motor.onestep()
time.sleep(DELAY)
for step in range(STEPS):
motor.onestep(direction=stepper.BACKWARD)
time.sleep(DELAY)
for step in range(STEPS):
motor.onestep(style=stepper.DOUBLE)
time.sleep(DELAY)
for step in range(STEPS):
motor.onestep(direction=stepper.BACKWARD, style=stepper.DOUBLE)
time.sleep(DELAY)
for step in range(STEPS):
motor.onestep(style=stepper.INTERLEAVE)
time.sleep(DELAY)
for step in range(STEPS):
motor.onestep(direction=stepper.BACKWARD, style=stepper.INTERLEAVE)
time.sleep(DELAY)
motor.release()

Thank You

References:

Thanks for reading this tutorial. If you have any technical inquiries, please post at Cytron Technical Forum.

Please be reminded, this tutorial is prepared for you to try and learn.
You are encouraged to improve the code for a better application.

Leave a Comment

Your email address will not be published.

Share this Tutorial

Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest
Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest

Latest Tutorial

Real-Time IoT Room Monitoring on Maker Pi Pico Using pyRTOS
Build an IoT Plant Monitoring System with MicroBit and Grove WiFi Module
Snap & Fit ABS Case and ICE Tower Cooling Fan Case Stress Test
Raspberry Pi Zero 2 W – Quad-core and 64-bit CPU
IoT Push Notification Using Rain Sensor with MicroBit
Tutorials of Cytron Technologies Scroll to Top