Go Down

Topic: Serial communications with XY-LPWM using Serial1 (Read 1 time) previous topic - next topic


I have arduino mega 2560 and LCD PWM generator with ttl.  i would like to control 4pin fan controlling PWM with arduino.


my code is:

void setup() {
  // Open serial communications and wait for port to open:

char buf[40];
int count=0;

void loop() { // run over and over
  if (Serial1.available()) {
  if (Serial.available()) {
    char ch = Serial.read();
      count = 0;   
    }else if(ch=='\n'){
      buf[count++] = ch;


comunication doestn work :/

I try to modify the code but it still does not work. on yesterday's communication attempt FAIL .....


@Hanzz23, I have suggested to the Moderator to move your question to its own Thread as there is no sign of an answer emerging in the present Thread

The words "doesn't work" give us no information from which to help you. Tell us in as much detail as possible what happens when you run your program.

Aslo make a drawing showing how you have everything connected and post a photo of the drawing.  See this  Simple Image Guide

Two or three hours spent thinking and reading documentation solves most programming problems.


are you transmitting '\r' to the program?
you don't appear to be adding an end of line (\r or \n) to your buffer before transmission over Serial1


I want to connect the arduino mega and pwm module with ttl communication (arduino pin RX18, TX19) did not send the wiring diagram. as it appeared in the previous post. my colleague has managed to solve the problem. i thought it would sound ..... i would like to control the pwm module with 4pin PC fan 12v and controlling pc ... after uploading the code to arduin, nothing will appear on serial communication. i can write command read and display FAIL. in the code I was inspired by youtube


I am sorry for my bad English...


thanks everbody! my code its works.  I did not have Both NL & CR on serial communication.......

Go Up