 
 void setup()
 {
-  Serial.begin(115200);
+  Serial.begin(57600);
   
-  DDRB = 0xFF;
-  DDRD = 0xFF;
+  bitClear(PORTB, PORTB1);
+  bitClear(PORTB, PORTB2);
+  
+  bitSet(DDRB, DDB1);
+  bitSet(DDRB, DDB2);
 }
-
-//// For teensy prototypes
-//void send_single_byte(uint8_t c)
-//{
-//  // D5 is clock, D4 is data
-//  for(uint8_t i = 0; i < 8; i++) {
-//    PORTD = (((c >> (7 - i)) & 0x01) << 4);
-//    PORTD = (((c >> (7 - i)) & 0x01) << 4) | 0x20;
-//  }
-//}
 
 // For blinkyboards
 void send_single_byte(uint8_t c)
 {
-  // D5 is clock, D4 is data
   for(uint8_t i = 0; i < 8; i++) {
-    PORTB = (((c >> (7 - i)) & 0x01) << 2);
-    PORTB = (((c >> (7 - i)) & 0x01) << 2) | 0x02;
+    // PB1 is clock, PB2 is data
+    if(c >> (7 - i) & 0x01) {
+      bitSet(PORTB, PORTB2);
+    }
+    else {
+      bitClear(PORTB, PORTB2);      
+    }
+    
+    bitSet(PORTB, PORTB1);
+    bitClear(PORTB, PORTB1);
   }
 }
 

  send_single_byte(0x80 | blue);
}

int j = 0;
int f = 0;
int k = 0;


uint8_t i = 0;
void loop()
{
  // If'n we get some data, switch to passthrough mode
  if(Serial.available()) {
    while(true) {
      send_single_byte(Serial.read());
      while(!Serial.available()) {}
    }
  }
    
  
  float brightness = random(100,100)/100.0;
  

  j = j + random(1,2);
  f = f + random(1,2);
  k = k + random(1,2);
  
  send_single_byte(0x00);
}


