title: Trying to send a float value over SPI between 2 Arduinos
body: <p>I am currently trying to send a float value across two Arduinos via SPI. Currently I am working to send a static value of 2.25 across and then read it via the <code>Serial.println()</code> command. I would then want to pass a float value from a linear displacement sensor. My end goal is to be able to have the master ask for information, the slave gathers the appropriate data and packages it and then master receives said data and does what it needs with it.</p>
  
  <p>Currently I am getting an error "call of overloaded 'println(byte [7])' is ambiguous" and I am not to sure why I am getting this error. I am currently a mechanical engineering student and I am crash-coursing myself through C/C++. I am not entirely positive about what I am doing. I know that a float is 4 bytes and I am attempting to create a buffer of 7 bytes to store the float and the '\n' char with room to spare. My current code is below.</p>
  
  <p>Master:</p>
  
  <pre><code>#include &lt;SPI.h&gt;
  void setup() {
    pinMode(SS,OUTPUT);
    digitalWrite(SS,HIGH);
    SPI.begin();
    SPI.setClockDivider(SPI_CLOCK_DIV4);
  }
  
  void loop() {
    digitalWrite(SS,LOW);
    float a = 2.25;
    SPI.transfer(a);
    SPI.transfer('\n');
    digitalWrite(SS,HIGH);
  }
  </code></pre>
  
  <p>My slave code is as follows:</p>
  
  <pre><code>#include &lt;SPI.h&gt;
  
  byte buf[7];
  volatile byte pos = 0;
  volatile boolean process_it = false;
  
  void setup() {
    Serial.begin(9600);
    pinMode(MISO,OUTPUT);
    digitalWrite(MISO,LOW);
    SPCR |= _BV(SPE); // SPI Enable, sets this Arduino to Slave
    SPCR |= _BV(SPIE); // SPI interrupt enabled
  }
  
  ISR(SPI_STC_vect) {
    // Interrupt Service Routine(SPI_(SPI Transfer Complete)_vector)
    byte c = SPDR;
    // SPDR = SPI Data Register, so you are saving the byte of information in that register to byte c
    if (pos &lt; sizeof buf) {
      buf[pos++] = c;
      if (c == '\n') {
        process_it = true;
      }
    }
  }
  
  void loop() {
    if (process_it = true) {
      Serial.println(buf);
      pos = 0;
      process_it = false;
    }
  }
  </code></pre>