6060-Push is a motion control module within the M5Stack structural system. It features a high-precision stepper motor, a Mega328 microprocessor, and a 1515 aluminum profile frame. By writing control programs, you can control the stepper motor. The module communicates via the RS485 serial bus, enabling high-precision displacement. It is suitable for various motion control scenarios, such as 3D printing and linear motion control.
Specification | Parameter |
---|---|
Net weight | 569.0g |
Gross weight | 569.0g |
Product size | 166 x 60 x 60mm |
Package size | 166 x 60 x 60mm |
#include <M5Stack.h>
#define RX_PIN 16
#define TX_PIN 17
#define X_LOCAL 40
#define Y_LOCAL 40
#define X_OFF 160
#define Y_OFF 30
int distance = 0; // Stepper motor movement step value
void header(const char *string, uint16_t color){ // Title
M5.Lcd.fillScreen(color);
M5.Lcd.setTextSize(1);
M5.Lcd.setTextColor(TFT_MAGENTA, TFT_BLUE);
M5.Lcd.fillRect(0, 0, 320, 30, TFT_BLUE);
M5.Lcd.setTextDatum(TC_DATUM);
M5.Lcd.drawString(string, 160, 3, 4);
}
void setup() {
M5.begin();
M5.Power.begin();
header("PUSH 6060", TFT_BLACK);
M5.Lcd.setTextFont(2);
M5.Lcd.setTextColor(TFT_WHITE, TFT_BLACK);
Serial2.begin(9600, SERIAL_8N1, RX_PIN, TX_PIN); // Configure Serial2
delay(500);
Serial2.print("ID=123\r\n"); // Serial2 outputs ID=123\r\n, configuring 6060 motor ID to 123
}
void loop() {
if(M5.BtnA.wasPressed()){ // Button A pressed, send ID\r\n to check 6060 motor ID
Serial2.print("ID\r\n");
}
if(M5.BtnB.wasPressed()){ // Button B pressed, send ID123:X%d\r\n to control absolute movement, where %d is the variable distance
if(distance < 50){
distance +=10;
Serial2.printf("ID123:X%d\r\n",distance);
}
}
if(M5.BtnC.wasPressed()){ // Button C pressed, send ID123Z\r\n to return motor to origin
Serial2.print("ID123Z\r\n");
}
if(Serial2.available()){ // Serial2 receives messages from 6060 and prints them
char c = Serial2.read();
Serial.print(c);
}
M5.update();
}