This an application-level module, which implements a motion & robotic control and it is totally customizable with different length. Packed with Stepper motor, Mega328 microprocessor, RS485 serial bus, 1515 framework. It realized a linear motion control, you can program the stepper motor to move a certain length with high precision. This type of module can be applied to 3D print, linear push and etc.
Resources | Parameter |
---|---|
Net weight | 569g |
Gross weight | 600g |
Product Size | 166*60*60mm |
Package Size | 166*60*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; //步进电机移动步进值
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 serial port 2
delay(500);
Serial2.print("ID=123\r\n"); //Serial port 2 output ID=123\r\n, configuration 6060 motor ID is 123
}
void loop() {
if(M5.BtnA.wasPressed()){ //Press button A to send ID\r\n to view 6060 motor ID.
Serial2.print("ID\r\n");
}
if(M5.BtnB.wasPressed()){ //Press button B to send the ID123: X%d\r\n to control the absolute travel, where %d is the variable distance
if(distance < 50){
distance +=10;
Serial2.printf("ID123:X%d\r\n",distance);
}
}
if(M5.BtnC.wasPressed()){ //Press C to send ID123Z\r\n and the motor returns to the origin.
Serial2.print("ID123Z\r\n");
}
if(Serial2.available()){ //Serial port 2 receives the message returned by 6060 and prints
char c = Serial2.read();
Serial.print(c);
}
M5.update();
}