Hello,
I tried to control XY-LPWM board for PWM generation with arduino using serial control provided by TX RX and GND pins on the PWM board.
I have connected Arduino 5V and GND pins to VIN+ and VIN-, respectively. Pin 11 as TX and pin 10 as RX, connected to RX and TX on PWM board, respectively.
Code is the example i've found on github:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
// set the data rate for the SoftwareSerial port
mySerial.begin(9600);
mySerial.print("Hello");
}
char buf[40];
int count=0;
void loop() { // run over and over
if (mySerial.available()) {
Serial.write(mySerial.read());
}
if (Serial.available()) {
char ch = Serial.read();
if(ch=='\r'){
buf[count]=0;
mySerial.print(buf);
count = 0;
}else if(ch=='\n'){
;
}else{
buf[count++] = ch;
}
}
}
On setup, i get FAIL from serial monitor.
Also, whatever i type into serial monitor i get FAIL as return.
Any ideas on how to solve this problem?
Thanks!