turntable G-code issue. October 27, 2018 07:09AM |
Registered: 9 years ago Posts: 288 |
// Example for M5Stack StepMotor Module (I2C verison) // 2018/6/27 JimmyLai #include #include void setup() { // put your setup code here, to run once: M5.begin(); Wire.begin(); Serial.begin(115200); m5.Lcd.setTextColor(WHITE, BLACK); m5.Lcd.setTextSize(2); m5.lcd.setBrightness(100); M5.Lcd.setCursor(4, 10); M5.Lcd.println("StepMotor Test: 0x70/0x71"); M5.Lcd.setCursor(4, 30); M5.Lcd.println("Press A: 0x70"); M5.Lcd.setCursor(4, 50); M5.Lcd.println("Press B: 0x71"); } void SendByte(byte addr, byte b) { Wire.beginTransmission(addr); Wire.write(b); Wire.endTransmission(); } void SendCommand(byte addr, char *c) { Wire.beginTransmission(addr); while ((*c) != 0) { Wire.write(*c); c++; } Wire.write(0x0d); Wire.write(0x0a); Wire.endTransmission(); } void loop() { if (digitalRead(39) == LOW) // A button { while (digitalRead(39) == LOW) delay(1); SendCommand(0x70, "G1 X0Y0Z200 F500"); while (digitalRead(39) == HIGH) delay(1); SendCommand(0x70, "G1 X0Y0Z0 F0"); } // Get Data from Module. Wire.requestFrom(0x70, 1); if (Wire.available() > 0) { int u = Wire.read(); if (u != 0) Serial.write(u); } Wire.requestFrom(0x71, 1); if (Wire.available() > 0) { int u = Wire.read(); if (u != 0) Serial.write(u); } delay(1); // Send Data to Module. while (Serial.available() > 0) { int inByte = Serial.read(); SendByte(0x70, inByte); SendByte(0x71, inByte); } }
Re: turntable G-code issue. October 27, 2018 07:53AM |
Admin Registered: 13 years ago Posts: 7,102 |
Re: turntable G-code issue. October 27, 2018 08:48AM |
Registered: 9 years ago Posts: 288 |
Re: turntable G-code issue. October 27, 2018 01:50PM |
Registered: 9 years ago Posts: 288 |
Re: turntable G-code issue. October 28, 2018 01:05PM |
Registered: 9 years ago Posts: 288 |