Index: trunk/toolbox/main.c
===================================================================
--- trunk/toolbox/main.c	(revision 200)
+++ trunk/toolbox/main.c	(revision 201)
@@ -30,6 +30,7 @@
 #include <util/delay.h>
 #include <tooltron.h>
 #include "jumptable.h"
+#include <toolbox_pindefs.h>
 #define TOOLBOX
 #define RELAY       _BV(PORTD4)
 #define VAC_SENSE   _BV(PIND3)
@@ -45,7 +46,7 @@
 #define ADDR 18
 #define DELIM '^'
 #define SERVER 1
-#define TURNON 'O'
+#define TURNON 'O' 'O''0'
 
 /***
  * TWAIT - minutes to wait before green button is pressed to kill power
@@ -205,7 +206,7 @@
 
                 if (r == (packet[0] ^ packet[1] ^ packet[2])) {
 
-                    if (packet[2] == TURNON) {
+                    if (packet[2] == TT_TON) {
                         state = ack;
                         break;
                     }
Index: trunk/common/toolbox_pindefs.h
===================================================================
--- trunk/common/toolbox_pindefs.h	(nonexistent)
+++ trunk/common/toolbox_pindefs.h	(revision 201)
@@ -0,0 +1,25 @@
+#ifndef _TOOLBOX_PIN_DEFS_H_
+#define _TOOLBOX_PIN_DEFS_H_
+
+#include <avr/io.h>
+
+// Relay
+#define RELAY_PORT  PORTD
+#define RELAY       _BV(PORTD4)
+
+// AC Voltage Sense
+#define VAC_PORT    PORTD
+#define VAC_SENSE   _BV(PIND3)
+
+// Buttons
+#define BUT_PORT    PINB
+#define BUT_RED     _BV(PINB4)
+#define BUT_BLACK   _BV(PINB3)
+
+// LEDs
+#define LED_PORT    PORTB
+#define LED_GREEN   _BV(PORTB2)
+#define LED_YELLOW  _BV(PORTB1)
+#define LED_RED     _BV(PORTB0)
+
+#endif
Index: trunk/common/tooltron.h
===================================================================
--- trunk/common/tooltron.h	(revision 200)
+++ trunk/common/tooltron.h	(revision 201)
@@ -25,19 +25,19 @@
 // Commonly used message bytes
 #define DELIM      '^'
 #define SERVER     1
-#define ACK_CRC    ADDR ^ SERVER
 
 // These are the bytes used in the messaage types
-#define TT_GET_KEY 'k'      // Get a key from the keyboard
-#define TT_ACK     'a'      // Ack
-#define TT_NACK    'n'      // Nack
-#define TT_TO      'f'      // State timeout
-#define TT_TIMEOUT 't'      // Packet timeout
-#define TT_RESET   'r'      // Tool reset request
-#define TT_BOOT    'b'      // Tool boot message
-#define TT_PROGM   'p'      // Program mode request
-#define TT_PROGD   'd'      // Program data
-#define TT_BAD     0        // If there was a packet parsing error
+#define TT_GET_KEY  'k'     // Get a key from the keyboard
+#define TT_ACK      'a'     // Ack
+#define TT_NACK     'n'     // Nack
+#define TT_TON      'o'     // Turn the tool on
+#define TT_TO       'f'     // State timeout
+#define TT_TIMEOUT  't'     // Packet timeout
+#define TT_RESET    'r'     // Tool reset request
+#define TT_BOOT     'b'     // Tool boot message
+#define TT_PROGM    'p'     // Program mode request
+#define TT_PROGD    'd'     // Program data
+#define TT_BAD       0      // If there was a packet parsing error
 
 // Number of bytes that the PROGx packets have in the payload
 #define PROGM_PACKET_SIZE 2
@@ -49,8 +49,11 @@
 // Memory locations
 #define MAIN_ADDR 0x0       // User code starts here
 #define BOOT_START 0x400    // Bootloader code starts here
+#define EEPROM_ADDR 1       // Location of the node's address in the EEPROM
 
 /****** Utility Definitions ******/
-#define TRUE  0
-#define FALSE 1
+#define TRUE    0x00
+#define FALSE   0x01
+#define ON      0x01
+#define OFF     0x00
 #endif
Index: trunk/bootloader/bootloader.h
===================================================================
--- trunk/bootloader/bootloader.h	(revision 200)
+++ trunk/bootloader/bootloader.h	(revision 201)
@@ -6,10 +6,8 @@
 #include <avr/wdt.h>
 #include <avr/fuse.h>
 #include <tooltron.h>
+#include <toolbox_pindefs.h>
 #include "rs485_poll.h"
 #include "packet.h"
 
-/** @brief This is the address of the tool. Change this pre program instance */
-//#define ADDR    18
-
 #endif
Index: trunk/bootloader/bootloader.c
===================================================================
--- trunk/bootloader/bootloader.c	(revision 200)
+++ trunk/bootloader/bootloader.c	(revision 201)
@@ -13,11 +13,6 @@
 // Error thresholds
 #define MAX_RETRIES 5       // Number of times to retry before giving up
 
-//Status LED
-#define LED_DDR  DDRB
-#define LED_PORT PORTB
-#define LED      PORTB1
-
 /**
  * Where we store the jump to user code. The jump address is in words
  * due to how the rjmp instruction works. It is 1 word below the bootloader
@@ -51,46 +46,52 @@
 int main(void) {
   uint8_t mbuf[PROGD_PACKET_SIZE];
   rjump_t jbuf;
-  uint16_t caddr = MAIN_ADDR;
-  uint8_t iteration;
+  uint16_t caddr;
+  uint16_t prog_len;
   uint8_t resp;
-  uint16_t prog_len;
   uint8_t i;
   uint8_t retries;
   uint8_t addr;
   uint8_t boot;
 
-retry_jpnt:
-  iteration = 0;
+  // This is where we jump to if we fail out because of retries
+  retry_jpnt:
+
+  // We set the variables here
+  caddr = MAIN_ADDR;
   retries = 0;
-  boot = 0;
-  addr = eeprom_read_byte(EEPROM_ADDR);
-  //set LED pins as output
-  LED_DDR = 0x07;
-  PORTB = 0x00;
+  boot = FALSE;
 
-  
+  // Grab the address from EEPROM
+  addr = eeprom_read_byte((void*)EEPROM_ADDR);
+
+  // Initialize the Pins
+  DDRB = LED_GREEN | LED_YELLOW | LED_RED;  // Set the LED pins as outputs
+  PORTB = 0x00;                             // LEDs on == in bootloader
+  DDRD = RELAY;                             // Set Relay as an output
+  PORTD = 0x00;                             // Turn relay off
+
   // Clear the watchdog timer
   if (MCUSR & _BV(WDRF)) {
       MCUSR &= ~_BV(WDRF);
       wdt_disable();
       WDTCSR = 0;
-      boot = 1;
+      boot = TRUE;
   }
 
-  if (!(PINB & (_BV(PINB3) | _BV(PINB4)))) {
-      PORTB |= 0x01;
-      boot = 1;
+  if (!(BUT_PORT & (BUT_RED | BUT_BLACK))) {
+      boot = TRUE;
   }
 
+  // Initialize the RS485
   rs485_init(BAUD9600);
 
-  //Start bootloading process
-  if (boot == 0) {
-      PORTB |= 0x07;
-      main_start();
+  //Execute user code if we aren't supposed to enter bootloading mode
+  if (boot == FALSE) {
+      goto run_user_code;
   }
 
+  // Send the boot packet
   send_packet(TT_BOOT, addr);
   resp = parse_packet(mbuf, addr);
 
@@ -108,7 +109,8 @@
 
   // Run user code
   } else {
-      PORTB = 0x07;
+      run_user_code:
+      LED_PORT = LED_GREEN | LED_YELLOW | LED_RED;
       main_start();
   }
 
@@ -119,7 +121,7 @@
 
       if (resp == TT_PROGD) {
           // We need to muck with the reset vector jump in the first page
-          if (iteration == 0) {
+          if (caddr == MAIN_ADDR) {
               // Store the jump to user code
               jbuf.bytes[0] = mbuf[0];
               jbuf.bytes[1] = mbuf[1];
@@ -134,8 +136,6 @@
               // Rewrite the reset vector to jump to the bootloader
               mbuf[0] = (BOOT_START/2 - 1) & 0xFF;
               mbuf[1] = 0xC0 | (((BOOT_START/2 - 1) >> 8) & 0x0F);
-
-              iteration = 1;
           }
 
           // Write the page to the flash
@@ -167,8 +167,8 @@
 
           onboard_program_write(BOOT_START - SPM_PAGESIZE, mbuf);
     
-          PORTB = 0x07;
-          main_start();
+          // Jump to user code that we just wrote
+          goto run_user_code;
       } else { 
           prog_len -= PROGD_PACKET_SIZE;
       }
Index: trunk/programmer/test/main.c
===================================================================
--- trunk/programmer/test/main.c	(revision 200)
+++ trunk/programmer/test/main.c	(revision 201)
@@ -28,6 +28,7 @@
 #include <stdint.h>
 #include <util/delay.h>
 #include <avr/wdt.h>
+#include <avr/eeprom.h>
 
 #define RELAY       _BV(PORTD4)
 #define VAC_SENSE   _BV(PIND3)
@@ -54,6 +55,7 @@
 #define TWARN   1
 #define TMAX    2
 
+
 uint8_t sec;
 uint8_t min;
 
@@ -98,6 +100,7 @@
     uint8_t packet[3];
     uint8_t ms_timer=0;
 
+    uint8_t myaddr;
 	/***** Start Start-up Sequence *****/
 	init_pins();		//Set pin directions
 	//	init_uart(51);		//Set registers for uart
@@ -104,15 +107,25 @@
 	/***** End Start-up Sequence *****/
 
     uint8_t r;
-    
-    PORTB &= ~_BV(PORTB0);
 
-    _delay_ms(1000);
-    PORTB |= _BV(PORTB0);
-    _delay_ms(1000);
-    reset();
+    //eeprom_write_byte(1, 18);
 
+    PORTB = 0x7;
+
+    //myaddr = eeprom_read_byte(1);
+    //if (myaddr == 18) {
+    //    PORTB = 0x7;
+    //}
+    //_delay_ms(1000);
+    //PORTB |= _BV(PORTB0);
+    //_delay_ms(1000);
+    //reset();
+
     while(1) {
+        _delay_ms(1000);
+        PORTB |= _BV(PORTB0);
+        _delay_ms(1000);
+        PORTB &= ~_BV(PORTB0);
     }
 
     return 0;
