 
 // the setup routine runs once when you press reset:
 void setup() {
-  Serial.begin(9600);
-  delay(1000);
   writeUv(0);
-  writeBatt(100);
+  writeBatt(0);
   writeIr(0);
   writeVis(0);
   advertisementData[9] = 0;
 
+  pinMode(UV_VAL, INPUT);
+  pinMode(BATT, INPUT);
+
+  pinMode(LED, OUTPUT);
+  digitalWrite(LED, LOW); // led off
   pinMode(UV_EN, OUTPUT);
   digitalWrite(UV_EN, HIGH); // enable the UV meter
   Serial.println("start");
   setup_TSL2561();
   Serial.println("setup done");
+  RFduinoBLE.advertisementInterval = 160;
   
   RFduinoBLE.deviceName="Whale";
 }

// the loop routine runs over and over again forever:
void loop() {
  word uv,vis, ir;
  uv = analogRead(2);
  writeUv(uv);
  readData(vis, ir);
  Serial.println(uv);
  Serial.println(batt);
  Serial.println(vis);
  Serial.println(ir);
  
  writeVis(vis);
  writeIr(ir);
  batt++;
  writeBatt(batt);
  RFduinoBLE.advertisementData = advertisementData;
  RFduinoBLE.begin();
  Serial.println("hi");
  
  delay(1000);
  RFduinoBLE.end();
}

void writeUv(word val) {

  Wire.beginOnPins(L_SCL, L_SDA);
  Wire.beginTransmission(TSL2561_ADDRESS);
  if (!(writeByte(TSL_REG_CONTROL, 0b11) && // powerup
        writeByte(TSL_REG_TIMING, 0b10 /* 402ms interval */ | 0x10 /* 16x gain */) &&
        writeByte(TSL_REG_INTERRUPT, 0))) { // no interrupts
        Serial.println("error in setup");
        Serial.println(getError());
