Hello there!
First of all, I've been following this topic as "guide": ADC library - Libraries - Arduino Forum
I'm trying to do exactly the same as wally123 with a little twist: to the max189 AIN pin I'm inputting some voltage generated by the pwm pins of an arduino uno. Basically, I have a file with a bunch of voltages I need to send to the adc.
I adjusted the pwm frequency so the signal oscillates a little less and verified the signal with an analogread pin. I used a low pass filter and TCCR1B = TCCR1B & B11111000 | B00000010) (ref here: https://arduino-info.wikispaces.com/Arduino-PWM-Frequency).
I tried writting my own code, but couldn't get any results, and I found the one by wally. And it's not working for me.
First of all, I don't understand the & 127 on the first result line. What does it mean? And if we want the 8 bits, why is there a shift of only 5?
I also defined the spi transfer mode as MSBFIRST, so I'm not sure what I should do with the bits.
I'm open to suggestions (regarding the pwm as an adc input as well, I'm not sure it's working). Any other suggestion to send an analog voltage to the adc input?
I didn't replied directly to the post because it is from 2011.
Thank you!