//mx1508_test.ino
//V2024/09/25 by JK1VCK
//blog URL:https://gijin77.blog.jp/archives/42286662.html
#include <ESP32MX1508.h>
#define LED 2 //ESP32 GPIO2
#define PINA 32 //ESP32 GPIO32
#define PINB 33 //ESP32 GPIO33
#define CH1 0 // 16 Channels (0-15) are availible
#define CH2 1 // Make sure each pin is a different channel and not in use by other PWM devices (servos, LED's, etc)
// Optional Parameters
#define RES 8 // Resolution in bits: 8 (0-255), 12 (0-4095), or 16 (0-65535)
#define FREQ 5000 // PWM Frequency in Hz
MX1508 motorA(PINA,PINB, CH1, CH2); // Default- 8 bit resoluion at 2500 Hz
//MX1508 motorA(PINA,PINB, CH1, CH2, RES); // Specify resolution
//MX1508 motorA(PINA,PINB, CH1, CH2, RES, FREQ); // Specify resolution and frequency
void setup() {
Serial.begin(115200);
delay(3000);
Serial.println();
Serial.println("<Program Start>");
pinMode(LED, OUTPUT);
for (int i=0;i<5;i++){
digitalWrite(LED, HIGH);delay(300);
digitalWrite(LED, LOW) ;delay(300);
}
}
void loop() {
Serial.println("<正転>");
motorA.motorGo(200); // Pass the speed to the motor: 0-255 for 8 bit resolution
delay(1000);
motorA.motorStop(); // Soft Stop -no argument
delay(1000);
Serial.println("<逆転>");
motorA.motorRev(200); // Pass the speed to the motor: 0-255 for 8 bit resolution
delay(1000);
motorA.motorBrake(); // Hard Stop -no arguement
delay(1000);
}





