Goal:
I am trying to send some characters to Arduino through serial from PC via a Prolific PL2303 USB to TTL converter(Chinese clone).
I have wrote a simple sketch(attached bellow) which should light up the LED if 'n' is found or should switch the LED off if 'f' is found from serial.
What's Happening:
I opened up the serial monitor. Send a character(say 'n' which should light up the LED). But nothing happened though the RX/TX LEDs flashed. Then I re opened the serial monitor. And just after re opening the serial monitor LED light up! Every time when I issue a character from serial monitor nothing happens. But just after re opening the monitor character is sent.
H/W Connection:
- Arduino Vin -> LiPo positive rail(+11V)
- Arduino GND -> LiPo negative rail(GND)
- Prolific GND -> Arduino GND
- Prolific RX -> Arduino TX
- Prolific TX -> Arduino RX
Arduino Sketch:
int led = 13;
void setup() {
// put your setup code here, to run once:
pinMode(led, OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
if(Serial.available() > 0){
char bytesReceived = Serial.read();
Serial.println(bytesReceived);
if(bytesReceived == 'n'){
digitalWrite(led, HIGH);
}
else if(bytesReceived == 'f'){
digitalWrite(led, LOW);
}
}
}
Additional Notes:
- Platform Windows 10
- Installed Prolific PL2303 driver from here
- This code is working using USB cable provided with Arduino.(I need longer cable)
Can't understand why this strange thing is happening. Any kind of help will be appreciated.
Thanks!
1 Answer 1
I have experienced similar behavior with clone chips. What worked for me is using ferrite choked USB cables similar to these; as you referenced as well, I observed that the problem occurs with either longer cable, or with cables without ferrite chokes on them. This might have to do with the PCB or the cheap chips being prone to electromagnetic interference.
-
I have purchased a 5m USB extension cable. It's working fine.Ashfaqur Rahaman– Ashfaqur Rahaman2018年09月26日 17:59:59 +00:00Commented Sep 26, 2018 at 17:59
When I run the script first time
.... what does that mean? .... please describe in detail the steps that you follow to run the script "the first time"