Reading potentiometer using ADC0831

I’ve got ADC0831, since that’s the only one my local electronics shop currently had in stock, but i’m struggling to get the digital output out of it

I need to get the value of potentiometer using only digital pins, in essence it should return 8bit (instead of 10) value just as if I’d use analog pin following this tutorial https://www.arduino.cc/en/Tutorial/Potentiometer

however all I get is all ones (11111111)

Wiring:
Yellow (pin 10) = CS
White (pin 12) = DO
Blue (pin 13) = CLK
Orange = output from potentiometer (value I want to read)

my current wiring diagram looks like this, the code I’m using is below

int CS = 10;
int CLK = 13;
int DO = 12;

byte result;

void setup()
{        
  pinMode(CS, OUTPUT);
  pinMode(CLK, OUTPUT);
  pinMode(DO, INPUT);
   
  digitalWrite(CS, HIGH);
  digitalWrite(CLK, LOW);
   
  Serial.begin(9600);
}

void loop()
{
  result = ADCread();
  Serial.println("Data: " + String(result));
  delay(1000);   
}

byte ADCread()
{ 
  byte _byte = 0;
  
  digitalWrite(CS, LOW);  
  digitalWrite(CLK, HIGH);
  delayMicroseconds(2);
  digitalWrite(CLK,LOW);
  delayMicroseconds(2);
  
  for (int i=7; i>=0; i--)
  {
    digitalWrite(CLK, HIGH);
    delayMicroseconds(2);
    digitalWrite(CLK, LOW);
    delayMicroseconds(2);
   
    if (digitalRead(DO))
      _byte |= (1 << i);
  }
    
  digitalWrite(CS, HIGH);
  return _byte; 
}

when reading the potentiometer using analog inputs everything’s fine, however I’d like to use the ADC as I have to move the project into raspberry pi later on, which has no analog inputs… the output I’m getting is 255 all the time

datasheet for ADC: http://www.ti.com/lit/ds/symlink/adc0832-n.pdf
the ADC is rotated to the right in the schematic;
pins from top left → GND, Vin(-), Vin(+), CS
pins from bottom left → Vref, DO, CLK, Vcc

I followed the tutorial above for reading potentiometer using analog inputs, which worked fine, then I tried adding ADC and using it according to http://forum.arduino.cc/index.php?topic=69413.0 but this quite didn’t work out

any suggestions?

any suggestions?

  1. Post a decent schematic that clearly shows all the connections, with the [u]IC pins labeled[/u]. Hand drawn is fine, Fritzing diagrams are generally worthless.

  2. Explain what is the program supposed to do, and what it does instead.

jremington: 1. Post a decent schematic that clearly shows all the connections, with the [u]IC pins labeled[/u]. Hand drawn is fine, Fritzing diagrams are generally worthless.

  1. Explain what is the program supposed to do, and what it does instead.

since I am no electrical engineer I can't draw schematics at all, therefore I have to use fritzing, but I gave it another try and tried to make it as clear as possible, the first post is also updated according to this

anyone?

since I am no electrical engineer I can't draw schematics at all, therefore I have to use fritzing,

No, you don't have to use Fritzing, and you don't have to be an electrical engineer to learn to draw a schematic diagram.

I don't want to try to figure out how you have that chip wired, in either of its two possible orientations (you might have plugged it in backwards), and I suspect no one else does either.

jremington: No, you don't have to use Fritzing, and you don't have to be an electrical engineer to learn to draw a schematic diagram.

I don't want to try to figure out how you have that chip wired, in either of its two possible orientations (you might have plugged it in backwards), and I suspect no one else does either.

the chip orientation is clearly stated in the first post and so is the connection (including pins), what you are doing is trying to establish some sort of authority in here for an unknown reason, which is completely useless and has no effect, as you're just being a dick without providing any help at all

I decided to unplug and move the ADC on the breadboard a little and after plugging it back in it started working, so I guess there was something wrong with some breadboard pins... thanks for "help"

One troubleshooting step is to measure all the wires/connections for continuity. These cheapo little wires tend to fail as well as the breadboard itself.