Hi there,
For a project I'm asked to get SPI data from the ADC of a Teensy 4.0 and to display the SPI data in the Arduino debugger. So after a couple of tries I managed to get SPI data varying with the position of the potentiometer, though the variation is not linear.
I get data from the MISO pin (number 12) and data ranges from 0 to 255, and stay at 0 on a great range of the potentiometer. After a slight rotation of the pot, data jumps to 8, after another to 125, then 255, which is the final value till I reach the end of the rotation of the pot. The data seems to jump from one value to another and I want to make this variation linear with the potentiometer. Anyone here would mind help me with that ?
Here is the code I use, anything could be wrong in this since I'm pretty new to the Arduino/Teensy/SPI environment...
Thanks a lot
For a project I'm asked to get SPI data from the ADC of a Teensy 4.0 and to display the SPI data in the Arduino debugger. So after a couple of tries I managed to get SPI data varying with the position of the potentiometer, though the variation is not linear.
I get data from the MISO pin (number 12) and data ranges from 0 to 255, and stay at 0 on a great range of the potentiometer. After a slight rotation of the pot, data jumps to 8, after another to 125, then 255, which is the final value till I reach the end of the rotation of the pot. The data seems to jump from one value to another and I want to make this variation linear with the potentiometer. Anyone here would mind help me with that ?
Here is the code I use, anything could be wrong in this since I'm pretty new to the Arduino/Teensy/SPI environment...
Code:
#include <SPI.h>
const int adcCS = 12;
int sensorValue = 0;
void setup() {
pinMode(adcCS, OUTPUT);
SPI.begin();
}
void loop() {
sensorValue = SPI.transfer(adcCS);
Serial.println(sensorValue);
delay(10);
}
Thanks a lot