The task I need to accomplish is as followed:
I have an analog/digital converter witch sends out a 10 bit signal. This bit signal needs to be transferred to an Arduino Uno using the SPI protocol. Because the SPI protocol works with a 16 bit pattern I need to expand the incoming signal. The Slave Arduino then needs to put out the transfered number as a decimal one
For my task I will imitated the ADC with another Arduino Uno setting as a Master, but unfortunately at the time I only have one Arduino so I can't test my code. And furthermore I don't really have a clue how to "expand" a 10 bit signal to a 16 bit one.
Code for the Master Arduino
#include <SPI.h>
#define SS 10
#define MOSI 11
void setup() {
pinMode(SS, OUTPUT);
pinMode(MOSI, OUTPUT);
SPI.beginTransaction(SPISettings(62500, LSBFIRST, SPI_MODE0));
}
void loop() {
byte x=0000001101;
byte y=0011111111;
digitalWrite(SS,LOW);
SPI.transfer(x,y);
digitalWrite(SS,HIGH);
delay(1000);
}
Code for the Slave Arduino
#include <SPI.h>
#define SS 10
#define MOSI 11
void setup() {
pinMode(SS, INPUT);
pinMode(MOSI, INPUT);
}
void loop() {
byte x=SPDR;
byte y=SPDR;
printf(x,DEC);
printf(y,DEC);
delay(1000);
}