//Definitions int Q0=12; //Read pins int Q1=11; int Q2=10; int Q3=9; int rb0=0; //Read bits int rb1=0; int rb2=0; int rb3=0; int CP=13; //Clock pin is LED pin int count=0; void setup() { Serial.begin(9600); pinMode(CP, OUTPUT); pinMode(Q0, INPUT); pinMode(Q1, INPUT); pinMode(Q2, INPUT); pinMode(Q3, INPUT); } void loop() { rb0=digitalRead(Q0); //Reads the counters bits rb1=digitalRead(Q1); rb2=digitalRead(Q2); rb3=digitalRead(Q3); count=rb0+2*rb1+4*rb2+8*rb3; //Converts the bits to decimal Serial.println(count); //Prints count to serial monitor digitalWrite(CP,HIGH); //Clock pulse advances count by one delay(3); //Just so you can see the LED better. digitalWrite(CP,LOW); delay(500); //Slows the Arduino so you can see the counting }