I know the 33 IOT doesn't have a SoftwareSerial equivalent, but the motor driver uses SoftwareSerial.
Is there any workaround that will allow me to use the 33 IOT with this motor controller? For context, I built a robot using the older Nano that supported SoftwareSerial and am wanting to switch out the Nano, but keep everything else.
Ok so I've attached my code here. Basically, I connected the logic pins on the motor controller to D0 and D1 on the Nano 33 IOT.
However, the serial communication doesn't seem to be working, because if I read from the connection (mySerial) or ask how many bytes are available to read, I get -1 (no data on serial) or 0 (no bytes to read) when I should be receiving a response from the board.
I know my board isn't dead because it works with the older Nano (using SoftwareSerial).
I also get the same results if I don't explicitly define the Serial UART and just use Serial1.
#include <Arduino.h>
#include "wiring_private.h"
Uart mySerial (&sercom0, 0, 1, SERCOM_RX_PAD_1, UART_TX_PAD_0);
//###################################################################
void setup() {
// Reassign pins 0 and 1 to SERCOM alt
pinPeripheral(0, PIO_SERCOM_ALT);
pinPeripheral(1, PIO_SERCOM_ALT);
// Start my new hardware serial
// reset the qik
digitalWrite(4, LOW);
pinMode(4, OUTPUT); // drive low
delay(1);
pinMode(4, INPUT); // return to high-impedance input (reset is internally pulled up on qik)
delay(10);
mySerial.begin(9600);
// Initialization command
mySerial.write(0xAA);
Serial.begin(9600);
while (!Serial);
Serial.println("Started");
}
//###################################################################
void loop() {
if (mySerial.available()) {
Serial.println(mySerial.read());
}
// Command to get firmware version
mySerial.write(0x81);
Serial.println(mySerial.available());
Serial.println(mySerial.read());
delay(1000);
}
//###################################################################
// Attach the interrupt handler to the SERCOM
void SERCOM0_Handler()
{
mySerial.IrqHandler();
}