cant compile, problem with libraries.

hi!! i have tried to compile the code below, but i m having the same errors over and over again. i have put the MIRF,nRF24L0, SPI libraries into the main library folder, but still im having the same errors.

please help!!! thank you very much.

/**
 * A Mirf example to test the latency between two Ardunio.
 *
 * Pins:
 * Hardware SPI:
 * MISO -> 12
 * MOSI -> 11
 * SCK -> 13
 *
 * Configurable:
 * CE -> 8
 * CSN -> 7
 *
 * This depends on the Spi Library:
 * http://www.arduino.cc/playground/Code/Spi
 */

#include <Spi.h>
#include <Mirf.h>
#include <nRF24L01.h>

void setup(){
  Serial.begin(9600);
  /*
   * Setup pins / SPI.
   */
   
  /* To change CE / CSN Pins:
   * 
   * Mirf.csnPin = 9;
   * Mirf.cePin = 7;
   */
   
  Mirf.init();
  
  /*
   * Configure reciving address.
   */
   
  Mirf.setRADDR((byte *)"clie1");
  
  /*
   * Set the payload length to sizeof(unsigned long) the
   * return type of millis().
   *
   * NB: payload on client and server must be the same.
   */
   
  Mirf.payload = sizeof(unsigned long);
  
  /*
   * Write channel and payload config then power up reciver.
   */
   
  /*
   * To change channel:
   * 
   * Mirf.channel = 10;
   *
   * NB: Make sure channel is legal in your area.
   */
   
  Mirf.config();
  
  Serial.println("Beginning ... "); 
}

void loop(){
  unsigned long time = millis();
  
  Mirf.setTADDR((byte *)"serv1");
  
  Mirf.send((byte *)&time);
  
  while(Mirf.isSending()){
  }
  Serial.println("Finished sending");
  delay(10);
  while(!Mirf.dataReady()){
    //Serial.println("Waiting");
  }
  
  Mirf.getData((byte *) &time);
  
  Serial.print("Ping: ");
  Serial.println((millis() - time));
  
  delay(1000);
}

the errors:
ping_client.cpp:21:17: error: Spi.h: No such file or directory
ping_client.cpp:22:18: error: Mirf.h: No such file or directory
ping_client.cpp:23:22: error: nRF24L01.h: No such file or directory
ping_client.cpp: In function ‘void setup()’:
ping_client:36: error: ‘Mirf’ was not declared in this scope
ping_client.cpp: In function ‘void loop()’:
ping_client:73: error: ‘Mirf’ was not declared in this scope

When adding new libraries you MUST restart all IDE's as libs are read/located at startup.

What is the purpose of the code?

this is just a code i got from a website, i m trying to interface arduino mega with a nordic rf transceiver nRF24L0+, to send a signal which will be received by another nRF24L0+ transceiver at another end.

i have the libraries as folders, but im not sure where i should place them. maybe i have placed them at the wrong place. so can u guide me on where do i place these libraries? i tried placing them in the main libraries folder, and restarted the IDE, but i still get the same error.

On my windows 7 PC new libraries could be placed as folder in

  • C:\Program Files (x86)\arduino-0021\libraries
    however this is not prefered imho

In the file menu choose preferences and you can see your sketchbook location. You can create a libraries folder in there and put the libs in there.
Details see http://www.arduino.cc/en/Hacking/Libraries

The reason to put new libs in the sketchbook is that they are preserved when upgrading the IDE. If you placed them well you should see themn the sketch menu => import library.

Hopes this helps.

Hi,

check also the case of the header file names, you include "Spi.h", but the actual file name is "SPI.h".

hello thanks for replies,

yeah i have solved library problems. i needed the Spi.h file rather than the SPI.h file... but still i m getting errors as shown below when im trying to upload programe to the arduino.

avrdude: stk500_getsync(): not in sync: resp=0x00
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51

Have you selected the COM port properly?
Tools menu > Serial port ...

yes i did try changing the comm port number on tools>>serial port,

but i m still getting th same error

Did you select the right board, also under the Tools menu?