 static bool radio_ack_pending  = false;
 static bool timing_change_done = false;
 static bool timing_high = false;
+static bool timing_resp = true;
 static uint8_t current_heart_rate_data[HR_MAX_PAYLOAD];
 
 const int analogInPin = I0; 
 
 int sensorValue = 200;
+
+void printData(aci_evt_t * aci_evt) {
+	int i = 0;
+	Serial.print(F("Data(HEX) : "));
+	for(i = 0; i < aci_evt->len - 2; i++)
+	{
+		Serial.print(aci_evt->params.data_received.rx_data.aci_data[i], HEX);
+		Serial.print(F(" "));
+	}
+	Serial.println(F(""));
+}
 
 void setup(void)
 { 

					//TRANSACTION_CONTINUE and TRANSACTION_COMPLETE
					//all other ACI commands will have status code of ACI_STATUS_SCUCCESS for a successful command         

					Serial.print("ACI Status of ACI Evt Cmd Rsp 0x");
					Serial.println(aci_evt->params.cmd_rsp.cmd_status, HEX);           
					Serial.print("ACI Command 0x");
					Serial.println(aci_evt->params.cmd_rsp.cmd_opcode, HEX);          
					Serial.println("Evt Cmd respone: Error. Arduino is in an while(1); loop");
					while (1);
				}        
				break;
				
			case ACI_EVT_PIPE_STATUS:
				Serial.println("Evt Pipe Status");
				/** check if the peer has subscribed to the Heart Rate Measurement Characteristic for Notifications
				*/
				if (lib_aci_is_pipe_available(&aci_state, PIPE_HEART_RATE_HEART_RATE_MEASUREMENT_TX) 

				radio_ack_pending = false;
				break;
	 	    case ACI_EVT_DATA_RECEIVED:
		        Serial.println(F("DATA RECEIVED"));
		        Serial.print(F("Pipe #: 0x"));
		        Serial.println(aci_evt->params.data_received.rx_data.pipe_number, HEX);
		        
		        switch(aci_evt->params.data_received.rx_data.pipe_number) {
		        	case PIPE_CONNECTIONCONTROL_CONNECTIONINTERVAL_RX_ACK_AUTO:
		        		Serial.println(F("CONNECTION_INTERVAL: "));
		        		
		        		printData(aci_evt);

		        		int x;

		        		uint8_t value_array[aci_evt->len - 2];
		        		uint16_t value;

						for(x = 0; x < aci_evt->len - 2; x++)
						{
							value_array[x] = aci_evt->params.data_received.rx_data.aci_data[x];
							Serial.print(value_array[x], BIN);
							Serial.print(" ");
						}
						Serial.println("");

						value = value_array[1] + ((uint16_t)value_array[0] << 8);
		        		Serial.print(F("Value in decimal: "));
		        		Serial.println(value, BIN);
		        		Serial.println(value, DEC);
		        		break;
		        	case PIPE_CONNECTIONCONTROL_SLAVELATENCY_RX_ACK_AUTO:
		        		Serial.println(F("SLAVELATENCY: "));
		        		break;	
		        	case PIPE_CONNECTIONCONTROL_SAMPLINGRATE_RX_ACK_AUTO:
		        		Serial.println(F("SAMPLING_RATE: "));
		        		printData(aci_evt);
		        		break;
		        	default:
		        		printData(aci_evt);
		        }
		        break; 
			 case ACI_EVT_DISCONNECTED:       
				/**
