Issues using tvout and pollserial

Hi all,

I am doing a small simple program to read from serial a set of characters and display it in a tv screen. The purpose is to have an arduino reading information from a set of sensors and them send the values to another arduino that just displays them in a tv screen.

I’m using the NTSCSerialTerm example with a minor change to fit a PAL TV.

Using the following code, all that I sent to the arduino using the Serial monitor is displayed in a tv screen

#include <TVout.h>
#include “pollserial.h”
#include <fontALL.h>

TVout TV;
pollserial pserial;
int idx = 0;
char c;
int i=0;

void setup() {
TV.begin(_PAL, 136, 96);
TV.select_font(font4x6);
TV.println(“Serial Terminal”);
TV.println("-- Version 0.1 --");
TV.set_hbi_hook(pserial.begin(9600));
}

void loop() {
while (pserial.available()) {

c = (char)pserial.read();

TV.print(40 + idx, 90, c);
idx +=4;

}
}

but if I use the next piece of code the values being displayed are funny characters that doesn’t correspond to what I’m typing. sometimes It prints my characters but in the wrong order, i.e. I type 1234 and it displays 3412.

The next piece of code is almost equal to the previous, but it olds the printing unitl it reads from serial queue the 5th element and until it reaches the 8th prints the characters. when it reads the 9th, resets the counter and cleans the specific area in the screen in order to re-print new information

#include <TVout.h>
#include “pollserial.h”
#include <fontALL.h>

TVout TV;
pollserial pserial;
int idx = 0;
char c;
int i=0;

void setup() {
TV.begin(_PAL, 136, 96);
TV.select_font(font4x6);
TV.println(“Serial Terminal”);
TV.println("-- Version 0.1 --");
TV.set_hbi_hook(pserial.begin(9600));
}

void loop() {
while (pserial.available()) {

c = (char)pserial.read();

i++;

if (i >= 5 && i <= 8)
{
TV.print(40 + idx, 90, c);
idx +=4;
}

if (i >= 9)
{
TV.print(40, 0, " ");
idx = 0;
i=0;
}
}
}

for now the values that enter in arduino are typed by me using serial monitor, no connection to other arduino is yet in place.

Do you had the same behavior while working with tvout library and pollserial? Am I doind anything wrong?

Attached you can find the tvout library

TVout-VE.zip (40.3 KB)

Solved.

For those interested in used PollSerial, the speed must be the slow as possible.

Problem solved with 4800 baud rate.