Arduino VTSerial Library

Arduino VTSerial Library

Mar 2012 - Updated to work with both Arduino 1 and older versions

This library allows integer and floating point numbers and text to be input via a serial terminal program supporting the VT100 escape sequences.
(We recommend the free TeraTerm software available at en.sourceforge.jp/projects/ttssh2/releases)

This library allows easy data entry of numbers and text into a program and also allows correction via the backspace key. Numbers are entered as a string and converted to an actual number before being returned to the calling program. Invalid characters entered are discarded.
The Backspace key only works back to the start of data entry not to the start of the line so any previous text displayed is not erased.

Download the VTSerial Library here

After downloading, extract the contents into the Arduino libraries directory where the Arduino software is installed.

Here is an example program showing the use of the VTSerial library

 

#include <VTSerial.h>

VTSerial vtSerial;

long mynum = 0;
float myfloat = 0;
char mytext[21];

void setup() {
  Serial.begin(9600);      // open the serial port at 9600 bps:    
  Serial.println("Example VTSerial program");  // prints a label  
  Serial.println("------------------------");  // prints carriage return    
}

void loop() {  

  // print labels 
  Serial.print("Enter a Number: ");  // prints a label
  mynum = vtSerial.ReadLong();      // read integer
  Serial.print("  Val=");
  Serial.print(mynum);               // echo the number received to screen
  Serial.println("");                // prints carriage return
  
  Serial.print("Enter a Float: ");   // prints a label
  myfloat = vtSerial.ReadFloat();   // read float
  Serial.print("  Val=");
  Serial.print(myfloat,4);           // echo the number received, to 4 DP
  Serial.println("");                // prints another carriage return  
  
  Serial.print("Enter Text: ");      // prints a label
  vtSerial.ReadText(mytext,20);     // Read text
  Serial.print("  Val=");
  Serial.print(mytext);              // echo the text received to screen
  Serial.println("");                // prints another carriage return    

}

Shopping Cart
0 items
 
DELIVERY/PAYMENT

Free Delivery Orders over £50

UK - £2.40 orders under £50
Airmail from £2.95 (+VAT)
More Details...

 
Brands
 
 Check out our videos
Follow us on:
acebook