BWD with User I/O in a PuTTY ANSI Terminal Window

Using PuTTY I have been able to make a working ANSI terminal on my WinXP PC.
I haven’t tried colors yet but screen control and cursor positioning work.
It took changing a setting to get screen clears to work not through background color change.

Anyway, here is a terminal app version of Blink Without Delay with Instant User I/O added.

Compiled & tested, hard part is setting up PuTTY right. Make it 80 chars x 25 lines, 57600 & defaults.

/* Blink without Delay -- with UL fixes and User Input, formatted for ANSI terminal
 
 Turns on and off a light emitting diode(LED) connected to a digital  
 pin, without using the delay() function.  This means that other code
 can run at the same time without being interrupted by the LED code.
 
 The circuit:
 * LED attached from pin 13 to ground.
 * Note: on most Arduinos, there is already an LED on the board
 that's attached to pin 13, so no hardware is needed for this example.
 
 
 created 2005
 by David A. Mellis
 modified 8 Feb 2010
 by Paul Stoffregen
 modifed to add User-I/O as BWD2 1 Jan 2014 
 by GoForSmoke :-P
 
 This example code is in the public domain.
 
 
 http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
 */

// constants won't change. Used here to 
// set pin numbers:
const int ledPin =  13;      // the number of the LED pin

// Variables will change:
int ledState = LOW;             // ledState used to set the LED
unsigned long previousMillis = 0;        // will store last time LED was updated

// the follow variables is a long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
unsigned long tWait = 1000UL;           // interval at which to blink (milliseconds)
unsigned long userFactor = 100UL;

void  displayData( void )
{
  Serial.write( 27 ); // Esc
  Serial.print( F("[12;12H") ); // set cursor
  Serial.write( 27 ); // Esc
  Serial.print( F("[K") ); // erase to end of line
  Serial.print( F("blink wait = ") );
  Serial.println( tWait );
  Serial.write( 27 ); // Esc
  Serial.print( F("[14;12H") ); // set cursor
  Serial.write( 27 ); // Esc
  Serial.print( F("[K" )); // erase to end of line
  Serial.print( F("factor = ") );
  Serial.println( userFactor );
  Serial.write( 27 ); // Esc
  Serial.print( F("[16;12H") ); // set cursor
  Serial.write( 27 ); // Esc
  Serial.print( F("[K") ); // erase to end of line
  Serial.print( F("User Entry? > ") );
}

void usageMsg( void )
{
  Serial.write( 27 ); // Esc
  Serial.print( F("[2J") ); // clear VT100 screen
  Serial.write( 27 ); // Esc
  Serial.print( F("[2;12H") ); // set cursor
  Serial.println ( F ( __FILE__ ) );
  Serial.println( F("\nUSER CONTROL CHARS\n") );
  Serial.println( F("F to blink faster, half factor") );
  Serial.println( F("S to blink slower, double factor") );
  Serial.println( F("digit entered x factor = blink\n") );
  displayData();
}

void setup() {
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);

  Serial.begin( 57600 ); 
  Serial.println( F("\nBWD2-PuTTY startup\n") );
  usageMsg(); 
}

void loop()
{
  // check to see if it's time to blink the LED; that is, if the 
  // difference between the current time and last time you blinked 
  // the LED is bigger than the interval at which you want to 
  // blink the LED.
  unsigned long currentMillis = millis();

  if ( currentMillis - previousMillis > tWait ) 
  {
    // save the last time you blinked the LED 
    previousMillis = currentMillis;   

    // if the LED is off turn it on and vice-versa:
    ledState = !ledState; // ! is logical not, opposite

      // set the LED with the ledState of the variable:
    digitalWrite( ledPin, ledState );
  } // end of blink state change

    //    lowest priority is serial data because it is slow.
  if ( Serial.available() )
  {
    char  serChar = Serial.read();

    if ( serChar >= '0' && serChar <= '9' ) // digits only
    {
      if ( serChar > '0' )
      {
        tWait = (long)( serChar - '0' ) * userFactor;
      }
      else
      {
        tWait = 10UL * userFactor;
      }
      displayData();
    } 
    else
    {
      serChar &= 0xDF; // strips bit 5, makes lowercase alphas uppercase
      if ( serChar == 'F' ) // faster
      {
        if ( userFactor > 1UL )
        {
          userFactor /= 2UL; // increase the frequency
          tWait /= 2UL;
        }
        displayData();
      }

      if ( serChar == 'S' )  // slower
      {
        if ( userFactor < 1000UL )
        {
          userFactor *= 2UL;  // decrease the frequency
          tWait *= 2UL;
        }
        displayData();
      }

      if ( serChar == 'H' )  // help
      {
        usageMsg();
      }
    }
  } // end of serial available

  //    finished all tasks  
}