Connect with us

C++ - Library help - Atmel Studio 6

Discussion in 'Microcontrollers, Programming and IoT' started by sheffladreece, Sep 12, 2015.

Scroll to continue with content
  1. sheffladreece


    Jan 24, 2014
    Hi all,

    Seem to be coming across the same problem over and over again which is putting me off my new found hobby of programming.

    Quick brief: trying to create wireless communication using nrf24l01 using atmega328p with a USBtinyISP on atmel studio 6.

    The problem I am currently facing is trying to build the program without it failing to build due to library errors. I.e, the project i am creating utilises the <SPI.h> library directory, however when I use this directory and build, it shows an error saying missing <arduino.h>, install the arduino.h header file and then it errors with missing <Wire.h> for example. Over and over with reoccurring failed builds due to no such file directory errors. Eventhough the project I am using is fairly concise and therefore is unlikely to use all of the libraries that I have to keep continually installing.

    Am I missing something to get it to build with just the header files that my specific project needs or do I have to continually install all of the library directories that is linked to SPI.h for example?

    Code provided by *Steve* much appreciated!

      Combines RF24's scanner with the LCD output to make a standalone scanner
    - - - - - - - - - - - - - - - - - -
      The circuit:
    * LCD pin 1 (gnd) to gnd
    * LCD pin 2 (Vcc) to +5v
    * LCD pin 3 (VO) to wiper of 20k pot between Vcc and gnd (contrast adj)
    * LCD pin 4 (RS) to digital pin 7
    * LCD pin 5 (R/W) to gnd
    * LCD pin 6 (clock/enable) to digital pin 6
    * LCD pin 7 (D0) UNUSED
    * LCD pin 8 (D1) UNUSED
    * LCD pin 9 (D2) UNUSED
    * LCD pin 10 (D3) UNUSED
    * LCD pin 11 (D4) to digital pin 5
    * LCD pin 12 (D5) to digital pin 4
    * LCD pin 13 (D6) to digital pin 3
    * LCD pin 14 (D7) to digital pin 2
    - - - - - - - - - - - - - - - - - -
    Example to detect interference on the various channels available.
    This is a good diagnostic tool to check whether you're picking a
    good channel for your application.
    Inspired by cpixip.
    The circuit:
    * nRF24L01 pin 1 gnd to gnd
    * nRF24L01 pin 2 Vcc tp 3v3
    * nRF24L01 pin 3 CE to 9
    * nRF24L01 pin 4 CSN to 10
    * nRF24L01 pin 5 SCK to 13
    * nRF24L01 pin 6 MOSI to 11
    * nRF24L01 pin 7 MISO to 12
    * nRF24L01 pin 8 IRQ UNUSED
    // include the library code:
    #include <LiquidCrystal.h>
    #include <SPI.h>
    #include "nRF24L01.h"
    #include "RF24.h"
    #include "printf.h"
      uint8_t num_rows = 2;
      uint8_t num_cols = 16;
      uint8_t scan_wide = (num_rows - 1) * num_cols;
    // initialize the library with the numbers of the interface pins
    LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
    // Hardware configuration
    // Set up nRF24L01 radio on SPI bus plus pins 9 & 10
    RF24 radio(2,3);
    // Channel info
      uint8_t num_channels = 128;
      uint8_t grp_size = num_channels / scan_wide;
      uint8_t values[num_channels];
    void setup() {
      // set up the LCD's number of columns and rows:
      lcd.begin(num_cols, num_rows);
      // Print a message to the LCD.
      // Get into standby mode
    const int num_reps = 100;
    void loop() {
      // set the cursor to column 0, line 1
      // (note: line 1 is the second row, since counting begins with 0):
      lcd.setCursor(0, 1);
      // Clear measurement values
      // Scan all channels num_reps times
      int rep_counter = num_reps;
      while (rep_counter--)
      int i = num_channels;
      while (i--)
      // Select this channel
      // Listen for a little
      // Did we get a carrier?
      if ( radio.testCarrier() )
      // Print out channel measurements, clamped to a single hex digit
      int i = 0;
      while ( i < num_channels )
      int group = 0;
      for ( int j=0; j < grp_size; j++)
      group += values[i];
      lcd.print(min(0xf,group), HEX);
  2. Old Steve

    Old Steve

    Jul 23, 2015
    I was leaving this to see if someone with more Atmel experience could/would answer. I don't have Atmel Studio, only the Arduino IDE.

    My copy of SPI.h, which came with Arduino, explicitly includes Arduino.h, and since it seems that you have a copy of the same version, your program will never build without it.

    Sounds like Atmel Studio 6 is based on the Arduino installation files?

    Arduino.h includes such things as stdlib.h, which are probably also needed by SPI.h:-

    #include <stdlib.h>
    #include <stdbool.h>
    #include <string.h>
    #include <math.h>
    #include <avr/pgmspace.h>
    #include <avr/io.h>
    #include <avr/interrupt.h>
    #include "binary.h"
    Don't you have a copy of Arduino.h or Wire.h, since it's lack also generates errors?
    If you do, the problem will be with your include path.
    Search your install directory for those files - if they are there, check your Atmel Studio settings.
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day