ADC library

Hi,

i tried MyADC::readADC(); and MyADC->readADC();
then ist was beyond my guessing capability ... :slight_smile:

following code works nice now:
Thanks for your help!

// MAX187 ADC

#include <SPI.h>
const int slaveSelectPin = 10;

int result;
byte highByte;
byte lowByte;
int refVolt = 5000;
int voltage = 0.0;

void setup() {

  pinMode (slaveSelectPin, OUTPUT);
  SPI.begin();
  Serial.begin (115200);
}

void loop(){
  highByte = 0;
  lowByte = 0;
    
  digitalWrite(slaveSelectPin,LOW);
  delayMicroseconds(10) ; 

  highByte = SPI.transfer(0x00);
  lowByte = SPI.transfer(0x00);
  
  digitalWrite(slaveSelectPin,HIGH); 
 
  result = (highByte & 127) << 5;
  result = result + (lowByte >> 3);

  voltage =  (float) refVolt/4096 * result;
  
  Serial.print(result, DEC); 
  Serial.print("\t");
  Serial.print(voltage); 
  Serial.println("mV"); 

delay (1000); // don't start blasting out of the serial port yet!
}