i have ran into a bit of trouble with a bit of code. it involves tvout and serial. the problem is that when i use the println function on a word it enters between every letter. is there a way to make it enter after the whole word?
#include <TVout.h>
#include <fontALL.h>
TVout TV;
const int buttonPin = 2;
const int ledPin = 13;
// the current state of the output pin
int buttonState; // the current reading from the input pin
int lastButtonState = LOW; // the previous reading from the input pin
int ledState = HIGH;
// the following variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long lastDebounceTime = 0; // the last time the output pin was toggled
long debounceDelay = 50; // the debounce time; increase if the output flickers
void setup() {
TV.begin(NTSC,120,96);
TV.select_font(font6x8);
TV.println("Starting MS-DOS...");
delay(5000);
TV.println("Ready");
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
if (Serial.available()) {
TV.println((char)Serial.read());
}
// read the state of the switch into a local variable:
int reading = digitalRead(buttonPin);
// check to see if you just pressed the button
// (i.e. the input went from LOW to HIGH), and you've waited
// long enough since the last press to ignore any noise:
// If the switch changed, due to noise or pressing:
if (reading != lastButtonState) {
// reset the debouncing timer
lastDebounceTime = millis();
TV.clear_screen();
}
if ((millis() - lastDebounceTime) > debounceDelay) {
// whatever the reading is at, it's been there for longer
// than the debounce delay, so take it as the actual current state:
buttonState = reading;
}
// set the LED using the state of the button:
digitalWrite(ledPin, buttonState);
// save the reading. Next time through the loop,
// it'll be the lastButtonState:
lastButtonState = reading;
}
the function println(); prints your data plus '\n' which meens that it starts on a new line,
what you probably want is just print(); and then when your determine your data is done/the end of your data you do a println("");
#include <TVout.h>
#include <fontALL.h>
char Str1[15];
TVout TV;
const int buttonPin = 2;
const int ledPin = 13;
// the current state of the output pin
int buttonState; // the current reading from the input pin
int lastButtonState = LOW; // the previous reading from the input pin
int ledState = HIGH;
// the following variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long lastDebounceTime = 0; // the last time the output pin was toggled
long debounceDelay = 50; // the debounce time; increase if the output flickers
void setup() {
TV.begin(NTSC,120,96);
TV.select_font(font6x8);
TV.println("Starting MS-DOS...");
delay(5000);
TV.println("Ready");
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
while(Serial.available){
if((char)Serial.read()=='\n'){
TV.println("");
}
else{
TV.print((char)Serial.read());
}
}
// read the state of the switch into a local variable:
int reading = digitalRead(buttonPin);
// check to see if you just pressed the button
// (i.e. the input went from LOW to HIGH), and you've waited
// long enough since the last press to ignore any noise:
// If the switch changed, due to noise or pressing:
if (reading != lastButtonState) {
// reset the debouncing timer
lastDebounceTime = millis();
TV.clear_screen();
TV.println("Starting MS-DOS...");
TV.println("Ready");
}
if ((millis() - lastDebounceTime) > debounceDelay) {
// whatever the reading is at, it's been there for longer
// than the debounce delay, so take it as the actual current state:
buttonState = reading;
}
// set the LED using the state of the button:
digitalWrite(ledPin, buttonState);
// save the reading. Next time through the loop,
// it'll be the lastButtonState:
lastButtonState = reading;
}
#include <TVout.h>
#include <fontALL.h>
TVout TV;
const int buttonPin = 2;
const int ledPin = 13;
// the current state of the output pin
int buttonState; // the current reading from the input pin
int lastButtonState = LOW; // the previous reading from the input pin
int ledState = HIGH;
// the following variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long lastDebounceTime = 0; // the last time the output pin was toggled
long debounceDelay = 50; // the debounce time; increase if the output flickers
void setup() {
TV.begin(NTSC,120,96);
TV.select_font(font6x8);
TV.println("Starting MS-DOS...");
delay(5000);
TV.println("Ready");
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
while(Serial.available()) {
if((char)Serial.read()=='\n'){
TV.println("");
}
else{
TV.print((char)Serial.read());
}
}
// read the state of the switch into a local variable:
int reading = digitalRead(buttonPin);
// check to see if you just pressed the button
// (i.e. the input went from LOW to HIGH), and you've waited
// long enough since the last press to ignore any noise:
// If the switch changed, due to noise or pressing:
if (reading != lastButtonState) {
// reset the debouncing timer
lastDebounceTime = millis();
TV.clear_screen();
}
if ((millis() - lastDebounceTime) > debounceDelay) {
// whatever the reading is at, it's been there for longer
// than the debounce delay, so take it as the actual current state:
buttonState = reading;
}
// set the LED using the state of the button:
digitalWrite(ledPin, buttonState);
// save the reading. Next time through the loop,
// it'll be the lastButtonState:
lastButtonState = reading;
}
It say if you get a CR then print a CR with a TV.println
But if you get a CR then simply printing it like the other characters is going to work the same.
Well if it is using the .print and the .println class then it will work.
What is actually important is the source of the serial data and if it contains any CR or LF characters. The OP has not said much about where the data that arrives through the serial port is coming from.