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 ADC0831 - Networking, Protocols, and Devices - Arduino Forum but this quite didn't work out
any suggestions?