How to use variable in serial

Hi guys i have an question. How do i give an variable to serial.begin for config. Eg serial.begin(9600, parity). Where parity holds SERIAL_8N1 OR SERIAL_7E1 ect.

Thanx

int parity = SERIAL_7E1;

Thanx for the reply ive tried it but doesnt work. It compiles but doesnt do anything. Doesnt read data

A better description of the problem please. What is the sending or receiving end? Serial Monitor, e.g., only supports 8N1.

This post is cross posted. looks like the OP might have got a solution here.

http://forum.arduino.cc/index.php?topic=535146.15

Tom.. :slight_smile:

I have an lcd screen displaying data. When i use the variable it just freezes an the screen stays blank. When i replace the variable with eg SERIAL_8N1 the data comes through.

Oh and no its not an cross post the other post was where signals were inverted. I fixed that wit an transistor and resistor. This is an different problem

What is the relationship between the lcd screen and the serial port? Is this a lcd screen with a serial interface? One usually does not read from a lcd screen, so it must be something else.

Time to post your code (or a representative example) so we can understand what you're doing.

The below behaves as expected

void setup()
{
  int parity = SERIAL_8N1;
  Serial.begin(57600, parity);

  Serial.println("Ready");
}

void loop() {

  if (Serial.available() > 0)
  {
    Serial.print((char)Serial.read());
  }
}

Serial also doesnt print anything. I will post code in an few.

Ok guys ive solved it i never use return function to exit while loop of nested if statement i used break. But hey im an vb programmer hah