vdip code writes an empty file

Hey all. I’m using a vdip1 to write a file to a memory stick, everyone’s doing it now. here’s the code:

#include <NewSoftSerial.h>

int count = 0;
int RTS = 5;
NewSoftSerial mySerial(2,3);

void setup(){
  Serial.begin(9600);
  mySerial.begin(9600);
  mySerial.print("IPA");
  mySerial.print(13, BYTE);
  delay(5000);
  Serial.println("initialized, hopefully.");
  
}

void loop(){
  while(digitalRead(RTS == LOW)){
    while(count < 5){
  mySerial.print("OPW LOG");
  mySerial.print(".TXT");
  delay(10);
  mySerial.print(13, BYTE);
  Serial.println("Opened File, hopefully."); 
  delay(500);
  mySerial.print("WRF 5");
  mySerial.print(13, BYTE);
  delay(10);
  mySerial.print("KSA ");
  Serial.println("Written to File, hopefully.");
  delay(100);
  mySerial.print("CLF LOG");
  mySerial.print(".TXT");
  mySerial.print(13, BYTE);
  Serial.println("Closed File");
  delay(1000);
  count++;
  if(count == 4){
    mySerial.print("SUD");
    mySerial.print(13, BYTE);
  }
}
}

}

But, it only writes an empty file. I’m thinking it’s gotta be some syntax problem or something. Anyone have an idea?

while(digitalRead(RTS == LOW)){

I think you have a ) in the wrong place. This code is comparing RTS to LOW. It they match it reads from pin 0. Otherwise, it reads from pin 1. I doubt that is what you want it to do. More likely, you want it to read from pin RTS, and do somethingi the value read from the pin is LOW.

RTS refers to a pin, not a value. Arduino syntax doesn’t require a pin name to actually have the word ‘pin’ in it, does it? I guess that is kind of confusing.

I read somewhere that you have to monitor the RTS line because if it’s high then it can’t accept any data at that moment.

OH! I get what you're saying. I'll make the changes and see if it works.

Alright! I got it working. You were right about the parentheses being wrong. I also happened to see that I had forgotten a (13, BYTE) after writing my data, so it was expecting another character. Maybe it was taking the “C” off of “CLF” so it was just receiving random jibberish commands? Here’s the final code for future readers:

#include <NewSoftSerial.h>

int count = 0;
int RTS = 5;
NewSoftSerial mySerial(2,3);

void setup(){
  Serial.begin(9600);
  mySerial.begin(9600);
  mySerial.print("IPA");
  mySerial.print(13, BYTE);
  delay(5000);
  Serial.println("initialized, hopefully.");
  
}

void loop(){
  while(digitalRead(RTS) == LOW){
    while(count < 5){
  mySerial.print("OPW LOG");
  mySerial.print(".TXT");
  delay(10);
  mySerial.print(13, BYTE);
  Serial.println("Opened File, hopefully."); 
  delay(500);
  mySerial.print("WRF 5");
  mySerial.print(13, BYTE);
  delay(10);
  mySerial.print("KSA ");
  mySerial.print(13, BYTE);
  Serial.println("Written to File, hopefully.");
  delay(100);
  mySerial.print("CLF LOG");
  mySerial.print(".TXT");
  mySerial.print(13, BYTE);
  Serial.println("Closed File");
  delay(1000);
  count++;
  if(count == 4){
    mySerial.print("SUD");
    mySerial.print(13, BYTE);
  }
}
}

}