Serial debugging


Here’s a little program I wrote to debug using serial.

You send commands to the board using the arduino IDE’s  built-in serial monitor. The board interprets these commands and turns on and off pins as a result. You might have to change some of the keys to make it work with your keyboard. With my laptop (dell inspiron 15r) the keys line up like a switch board.

I was going to show how I fixed some of the wiring with this program but I couldn’t because my etherten isn’t working at the moment.

Enjoy.

 
/* 
Switchboard debugging program created by Lochie Ferrier (www.lochieferrier.com).
Use it wherever the hell you like.
*/


int incomingByte;      // a variable to read incoming serial data into

void setup() {
  // initialize serial communication:
  Serial.begin(9600);
  // initialize the LED pin as an output:
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(2, OUTPUT);
  pinMode(1, OUTPUT);
  pinMode(0, OUTPUT);
  pinMode(A0, OUTPUT);
  pinMode(A1, OUTPUT);
  pinMode(A2, OUTPUT);
  pinMode(A3, OUTPUT);
  pinMode(A4, OUTPUT);
  pinMode(A5, OUTPUT);
  
  
  
}

void loop() {
  digitalWrite(0, HIGH);3
  // see if there's incoming serial data:
  if (Serial.available() > 0) {
    // read the oldest byte in the serial buffer:
    incomingByte = Serial.read();
    // if it's a capital H (ASCII 72), turn on the LED:
        if (incomingByte == '-') {
      digitalWrite(0, HIGH);
    } 
        if (incomingByte == '[') {
      digitalWrite(0, LOW);
    } 
    if (incomingByte == '1') {
      digitalWrite(1, HIGH);
    } 
        if (incomingByte == 'q') {
      digitalWrite(1, LOW);
    } 
        if (incomingByte == '2') {
      digitalWrite(2, HIGH);
    } 
        if (incomingByte == 'w') {
      digitalWrite(2, LOW);
    } 
        if (incomingByte == '3') {
      digitalWrite(3, HIGH);
    } 
        if (incomingByte == 'e') {
      digitalWrite(3, LOW);
    } 
        if (incomingByte == '4') {
      digitalWrite(4, HIGH);
    } 
        if (incomingByte == 'r') {
      digitalWrite(4, LOW);
    } 
    if (incomingByte == '5') {
      digitalWrite(5, HIGH);
    } 
        if (incomingByte == 't') {
      digitalWrite(5, LOW);
    } 
        if (incomingByte == '6') {
      digitalWrite(6, HIGH);
    } 
        if (incomingByte == 'y') {
      digitalWrite(6, LOW);
       }    
      if (incomingByte == '7') {
      digitalWrite(7, HIGH);
    } 
        if (incomingByte == 'u') {
      digitalWrite(7, LOW);
    }
          if (incomingByte == '8') {
      digitalWrite(8, HIGH);
    } 
        if (incomingByte == 'i') {
      digitalWrite(8, LOW);
    }
              if (incomingByte == '9') {
      digitalWrite(9, HIGH);
    } 
        if (incomingByte == 'o') {
      digitalWrite(9, LOW);
    }
                  if (incomingByte == '0') {
      digitalWrite(10, HIGH);
    } 
        if (incomingByte == 'p') {
      digitalWrite(10, LOW);
    }
                      if (incomingByte == 'a') {
      digitalWrite(11, HIGH);
    } 
        if (incomingByte == 'z') {
      digitalWrite(11, LOW);
    }                 
    if (incomingByte == 's') {
      digitalWrite(12, HIGH);
    } 
        if (incomingByte == 'x') {
      digitalWrite(12, LOW);
    }
        if (incomingByte == 'd') {
      digitalWrite(13, HIGH);
    } 
        if (incomingByte == 'c') {
      digitalWrite(13, LOW);
    }
            if (incomingByte == 'f') {
      digitalWrite(A0, HIGH);
    } 
        if (incomingByte == 'v') {
      digitalWrite(A0, LOW);
    }
                if (incomingByte == 'g') {
      digitalWrite(A1, HIGH);
    } 
        if (incomingByte == 'b') {
      digitalWrite(A1, LOW);
    }
                    if (incomingByte == 'h') {
      digitalWrite(A2, HIGH);
    } 
        if (incomingByte == 'n') {
      digitalWrite(A2, LOW);
    }
                        if (incomingByte == 'j') {
      digitalWrite(A3, HIGH);
    } 
        if (incomingByte == 'm') {
      digitalWrite(A3, LOW);
    }
                            if (incomingByte == 'k') {
      digitalWrite(A4, HIGH);
    } 
        if (incomingByte == ',') {
      digitalWrite(A4, LOW);
    }
                                if (incomingByte == 'l') {
      digitalWrite(A5, HIGH);
    } 
        if (incomingByte == '.') {
      digitalWrite(A5, LOW);
    }
      
    }
  
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s