I have a very simple piece of code for Arduino Uno. Using SoftwareSerial lib.
#include <SoftwareSerial.h>
#define rxPin 6
#define txPin 7
SoftwareSerial mySerial(rxPin, txPin);
void setup() {
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
Serial.begin(9600);
mySerial.begin(2400);
Serial.println("Serial init");
}
void loop() {
delay(2000);
Serial.println("Serial link started");
mySerial.write(0x15);
if(mySerial.available() ){
int incomingByte = mySerial.read();
Serial.print(incomingByte);
Serial.print(" is here");
}
}
rxPin and txPin are connected directly to each other. Arduino is also connected to PC throught USB. I have no respone from mySerial.available() loop, mySerial.read() returns -1. Does anyone know, where could be the problem? SoftwareSerial doesnt work for me.