Potentiometer to Binary outputs pins defined.

I am almost completed the code but now stuck mapping the numbers to BINARY and displaying them on there ports. The initial values from the pot are properly defined range. The range matches a device that I will be driving from the Arduino but the value still needs to be converted to binary. Current Code: missing binary conversion code. Need some guidance on how to convert binary and assign the values to Digital Pins. Starting Pin should be D2 - D8 After reading through the code Im looking for constructive criticism on how to improve the code.

const int analogInPin = A0; // Analog input pin that the potentiometer is attached to const int analogOutPin = 9; // Analog output pin that the LED is attached to

int sensorValue = 0; // value read from the pot int outputValue = 0; // value output to the PWM (analog out)

void setup() { // initialize serial communications at 9600 bps: Serial.begin(9600); }

void loop() { // read the analog in value: sensorValue = analogRead(analogInPin); // map it to the range of the analog out: outputValue = map(sensorValue, 0, 1023, 0, 255); // change the analog out value: analogWrite(analogOutPin, outputValue);

// print the results to the serial monitor: Serial.print("sensor = " ); Serial.print(sensorValue); Serial.print("\t output = "); Serial.println(outputValue);

// wait 2 milliseconds before the next loop // for the analog-to-digital converter to settle // after the last reading: delay(2); }

What do you mean by "binary conversion"? It's all already in binary.

Please use code tags when posting code.

I was not being clear enough.

After I find the pot value I want to convert the INTEGER value to BINARY. easy enough.

sensorValue = analogRead(analogInPin); // read the analog in value: outputValue = map(sensorValue, 0, 1023, 0, 255); // map it to the range of the analog out: analogWrite(analogOutPin, outputValue); // change the analog out value: String stringOne = String(255, BIN); //stringOne = 1111 1111

Now that I have it converted how do I write the value to the digital outputs in one command. I have seen example code that cycles through the and writes one bit at a time. But I was wondering if there was one command that can write the whole string at once. Starting at D2

Look for "direct port manipulation".

Have a look at the C++ bit-fiddling operators.

int value = whatever;

for(int  = 0; i<16; i++) {
  Serial.print((value & (1<<i)) ? '1' : '0')
}
Serial.println();

If you don't want to do the fiddly stuff yourself, you can use bitRead and bitWrite.