Ok, I have a working code that is far more complicated than the question I am about to ask, so I apologize for my utter noobness...
I have 4 push buttons. One to increment my counter up by 10, one to increment up by 1, one for down 1 and one for down 10. This code displays the counter value great on the LCD:
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 2, 3, 4, 5);
const int upTenButtonPin = 9;
const int upOneButtonPin = 10;
const int downOneButtonPin = 11;
const int downTenButtonPin = 12;
int buttonPushCounter = 0;
int buttonState = 0;
int lastUpTenButtonState = 0;
int lastUpOneButtonState = 0;
int lastDownOneButtonState = 0;
int lastDownTenButtonState = 0;
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Button Pushes:");
}
void loop() {
pinMode(upTenButtonPin, INPUT);
pinMode (upOneButtonPin, INPUT);
pinMode(downOneButtonPin, INPUT);
pinMode(downTenButtonPin, INPUT);
int upTenButtonState = digitalRead(upTenButtonPin);
if (upTenButtonState != lastUpTenButtonState) {
if (upTenButtonState == HIGH) {
buttonPushCounter += 10;
}
}
lastUpTenButtonState = upTenButtonState;
int upOneButtonState = digitalRead(upOneButtonPin);
if (upOneButtonState != lastUpOneButtonState) {
if (upOneButtonState == HIGH) {
buttonPushCounter ++;
}
}
lastUpOneButtonState = upOneButtonState;
int downOneButtonState = digitalRead(downOneButtonPin);
if (downOneButtonState != lastDownOneButtonState) {
if (downOneButtonState == HIGH) {
buttonPushCounter --;
}
}
lastDownOneButtonState = downOneButtonState;
int downTenButtonState = digitalRead(downTenButtonPin);
if (downTenButtonState != lastDownTenButtonState) {
if (downTenButtonState == HIGH) {
buttonPushCounter -= 10;
}
}
lastDownTenButtonState = downTenButtonState;
delay(100);
pinMode(upTenButtonPin, OUTPUT);
pinMode(upOneButtonPin, OUTPUT);
pinMode(downOneButtonPin, OUTPUT);
pinMode(downTenButtonPin, OUTPUT);
lcd.setCursor(0, 1);
lcd.print(buttonPushCounter, DEC);
}
However, I now would like to take this counter value and output it to pins D2 - D9 as an 8-bit binary number for an ADC (R-2R ladder setup). What do I do in order to "print" the counter value to the 8 pins?
Any help is appreciated!