Help with adding a Max3232 to my Sketch (SOLVED)

Hello People.
Been a newbe to all this I have some how manged to get so far with my project but have hit a total blank about adding a RS232 output into my Sketch. This is my sketch so far and I wounder if any one could help me with the next bit.

#include <Wire.h>
#include <Adafruit_ADS1015.h>
 Adafruit_ADS1115 ads1(0x48); /* Use this for the 16-bit version */
 Adafruit_ADS1115 ads2(0x49);
 
 char * format5(int x)
{
    static char buffer[6];  // 5 chars + terminating NUL
    snprintf(buffer, sizeof buffer, "%5d", x);
    return buffer;
}

void setup() {
    Serial.begin(9600);
   ads1.setGain(GAIN_TWO);          // 2x gain   +/- 2.048V  1 bit = 1mV
  ads2.setGain(GAIN_TWO);          // 2x gain   +/- 2.048V  1 bit = 1mV      

  ads1.begin();
  ads2.begin();
}

void loop(){
 int16_t results01,results02,results03;

  results01 = ads1.readADC_Differential_2_3(); // x pin 1-2
  results02 = ads1.readADC_Differential_0_1(); // y pin 3-4
  results03 = ads2.readADC_Differential_2_3(); // z pin 5-6
    
    Serial.print("X "); 
    Serial.print(format5(results01 * 0.0625)); // CP cell 1 to remote
    Serial.print(" Y ");  
    Serial.print(format5(results02 * 0.0625)); // Field Gradient cell 1 to cell 2
    Serial.print(" Z "); 
    Serial.println(format5(results03 * 0.0625)); // Contact CP Tip to cell 1
    Serial.println(); 
  delay(500);

i am trying to add the following and change it some how.

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(57600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }


  Serial.println("Goodnight moon!");

  // set the data rate for the SoftwareSerial port
  mySerial.begin(4800);
  mySerial.println("Hello, world?");
}

void loop() { // run over and over
  if (mySerial.available()) {
    Serial.write(mySerial.read());
  }
  if (Serial.available()) {
    mySerial.write(Serial.read());
  }
}

Thanks for and advice

Joe

Your RS-232 adapter just makes physical connections to the RX, TX, 5 volt and ground pins of your Arduino, which you probably already have connected. It converts the digital in and out of the Arduino pins to RS-232. Your program doesn't care no will it be able to even know you have done the conversion.

Just take care of the serial in and out in your code and the adapter will take care of the rest.

Paul

so all i need to add is

#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(4800);
 



}

and add myserial. infront of all my prints. ie

Serial.print("X "); 
    mySerial.print(format5(results01 * 0.0625)); // CP cell 1 to remote
    mySerial.print(" Y ");  
    mySerial.print(format5(results02 * 0.0625)); // Field Gradient cell 1 to cell 2
    mySerial.print(" Z "); 
    mySerial.println(format5(results03 * 0.0625)); // Contact CP Tip to cell 1
    mySerial.println();

Looks like it is ok. What do you have on the other end of the RS-232 to verify it is working?

Paul

i have the computer software i want it to talk to . But as a quick check i will use hyperterminal.

regards

Reseni:
i have the computer software i want it to talk to . But as a quick check i will use hyperterminal.

regards

Then that tells me you have an RS-232 adapter on the computer. Right.

Paul

yes i do.

just to verify im using pin 10 and 11 on my uno board and not pin 1 and 2 that say tx and rx

regards

Reseni:
yes i do.

just to verify im using pin 10 and 11 on my uno board and not pin 1 and 2 that say tx and rx

regards

Give an update when it works!

Paul

Er bloody hell it works.

Cheers Paul you are a Star.

Joe

cp capture.JPG

GReat! Now go change the title of your post to "(solved)".

Paul