#include "binary.h"

#include <Arduino.h>
#include "searduino.h"


void
binary(byte sensorValue)
{
  byte tmp = 0; //temporary variable to store bitshifted byte
  char i;
  for (i = 7; i >= 0; i--)
    {
      tmp = sensorValue >> i; // starts with bit7, shifting it to position 0.

      if (tmp & 1) // performs a bitwise AND operation on bit 0.
	{
	  digitalWrite((i + 2), HIGH); // if a 1 in position 0 is TRUE, writes HIGH to the led representing bit 7, in this case pin 9.
	}
      else
	{
	  digitalWrite((i + 2), LOW);
	}
    }
}
