contiued work on light/bluetooth algorithm