Hello!
I need to send by SPI the bit sequence '1000' to a MCP3208 ADC and then receive and send the received data by UART. I'm using the following code:
#include <SPI.h>
void setup (void) {
Serial.begin(115200); //set baud rate to 115200 for usart
digitalWrite(SS, HIGH); // disable Slave Select
SPI.begin ();
SPI.setClockDivider(SPI_CLOCK_DIV8);//divide the clock by 8
}
void loop (void) {
char c;
digitalWrite(SS, LOW); // enable Slave Select
// send test string
for (const char * p = "1000" ; c = *p; p++) {
SPI.transfer (c);
Serial.print(c);
}
digitalWrite(SS, HIGH); // disable Slave Select
delay(250);
}
But I'm not very sure If this is doing what it supposed to do, specially with the SPI.transfer(c) method. How can I fix my code to send the '1000' and receive the data?
Thanks in advance