Error compiling some code.

I am using 1.0.3 and am trying to compile and upload some code to an ATmega328P-PU through an arduino uno R3. So, this is not the original microcontroller, however, it does have the bootloader.

Code:

#include <LiquidCrystal.h>
#include <nikonIrControl.h>


LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

int CameraIrPin = 13;   // LED connected to digital pin 13
int configPin = 2;      // potentiometer to pin analogic 2
int selection = 0;      // inizializzo la variabile di attesa

#define LENARRAY 14 // number of element of array
int confArray[LENARRAY] = {0, 5, 10, 15, 20, 24, 25, 30, 35, 40, 45, 50, 55, 60}; // wait time in seconds
long previousMillis = 0; 

byte newChar[8] = {  //copyraght character
	B00000,
	B01110,
	B10001,
	B11111,
	B11001,
	B11111,
	B10001,
	B01110
};

void setup()  
{
  pinMode(CameraIrPin, OUTPUT); // config digital pin as output
  lcd.begin(16,2) ;  // inizializza LCD
  
  lcd.createChar(0, newChar);
  lcd.setCursor(0,1);
  lcd.print("By Aaron Fuller");
  lcd.write(byte(0));
  lcd.setCursor(0,0);
  lcd.print(" Intervalometer");
  delayMicroseconds(7000);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("  Designed to");
  lcd.setCursor(0,1);
  lcd.print(" NIKON D SERIES");
  delayMicroseconds(6000);
  
}

void loop()     
{
  selection = analogRead(configPin); //read pot value (from 0 to 1023)
  selection = map(selection,0, 1023, 1, LENARRAY) ; // resize the value to other like array

  lcd.setCursor(0,0) ;
  lcd.print("INTERVAL:");
  lcd.print(confArray[selection]); //show the set of second
  lcd.print(" sec      "); // keep this space
  
  lcd.setCursor(0,1); 
  lcd.print("RELEASE:");
  unsigned long currentMillis = millis();
  lcd.print(confArray[selection] - ((currentMillis - previousMillis)/1000)); // countdown 
                                                                             // 
  lcd.print("       ");  // clear lcd
  
  // time control
  if((currentMillis - previousMillis) > (confArray[selection]*1000)) {
    previousMillis = currentMillis;   // i save the last shot
    cameraSnap(CameraIrPin);
  }
}

Error:

In file included from FAIH9TOGSLF38FA.ino:2:
C:\Users\me\Documents\Arduino\libraries\nikonIrControl/nikonIrControl.h:7:22: error: WProgram.h: No such file or directory
In file included from FAIH9TOGSLF38FA.ino:2:
C:\Users\me\Documents\Arduino\libraries\nikonIrControl/nikonIrControl.h: In function 'void on(int, int)':
C:\Users\me\Documents\Arduino\libraries\nikonIrControl/nikonIrControl.h:17: error: 'HIGH' was not declared in this scope
C:\Users\me\Documents\Arduino\libraries\nikonIrControl/nikonIrControl.h:17: error: 'digitalWrite' was not declared in this scope
C:\Users\me\Documents\Arduino\libraries\nikonIrControl/nikonIrControl.h:18: error: 'delayMicroseconds' was not declared in this scope
C:\Users\me\Documents\Arduino\libraries\nikonIrControl/nikonIrControl.h:19: error: 'LOW' was not declared in this scope
C:\Users\me\Documents\Arduino\libraries\nikonIrControl/nikonIrControl.h: In function 'void cameraSnap(int)':
C:\Users\me\Documents\Arduino\libraries\nikonIrControl/nikonIrControl.h:30: error: 'delayMicroseconds' was not declared in this scope

In C:\Users\me\Documents\Arduino\libraries\nikonIrControl/nikonIrControl.h change Wprogram.h to Arduino.h to make the library more Arduino 1.0 compatible.

I do not have the software to edit the .h file, is this is what you're suggesting.

Use Wordpad, or download Notepad++

Beatz1337: I do not have the software to edit the .h file, is this is what you're suggesting.

All you need is a text editor...

Yes, but I am on windows eight, and if I open it with a text editor it will no longer be a .h file, but a .txt file.

So save it as a text file and rename it a .h file when you have finished.

Beatz1337: Yes, but I am on windows eight, and if I open it with a text editor it will no longer be a .h file, but a .txt file.

Only if you save it as a .txt instead of a .h

Have you used windows eight? It does not have an "edit" option, the only way to open it is to select a default program. Then, it automatically saves it as a .txt I'm going to try what grumpy suggested.

Beatz1337: Have you used windows eight?

I'm not into masochism.

It does not have an "edit" option, the only way to open it is to select a default program. Then, it automatically saves it as a .txt

Then do what Mike said and rename the file afterwords.

Thank you, that worked. However, I get a new error.

FAIH9TOGSLF38FA.ino: In function 'void loop()':
FAIH9TOGSLF38FA:67: error: 'cameraSnap' was not declared in this scope

Arrch:

Beatz1337: Have you used windows eight?

I'm not into masochism.

I installed it to try it out once. I managed about 15 minutes before I formatted the hard drive, installed Linux, and destroyed the DVD with a pair of wire cutters.

Never again ;)

In my usual, opinionated, way I just had to moan about it: http://www.hacking.majenko.co.uk/microsoft-sunk-to-an-all-time-low

If you only tried it for 15 minutes, that is not nearly enough time to adapt to a new interface. Can you help me with my code, or are we just going to talk about operating systems?

FAIH9TOGSLF38FA:67: error: 'cameraSnap' was not declared in this scope

You haven't declared the function "cameraSnap" anywhere. Is it supposed to be in the Nikon library?

@majenko: good point! It seems the targeted audience of usoft (and the newest linux distros as well) are going to be teenagers, managers, and members of parliament… :slight_smile:
Old good XP…

majenko:

FAIH9TOGSLF38FA:67: error: 'cameraSnap' was not declared in this scope

You haven't declared the function "cameraSnap" anywhere. Is it supposed to be in the Nikon library?

Yes, it's supposed to be.

(googles briefly)

Gah! Another library written by a clueless moron. Complete functions in a header file?! Gah! Idiot! (Not you.)

It looks like (even though it was written by someone who knows nothing) it should work fine, so it is possible that in editing it, windows 8 has broken it.

If I were you, I would just copy and paste the two functions that are in that header file and place them directly in your sketch, and remove the reference to that header file from the top of your sketch.

majenko: (googles briefly)

Gah! Another library written by a clueless moron. Complete functions in a header file?! Gah! Idiot! (Not you.)

It looks like (even though it was written by someone who knows nothing) it should work fine, so it is possible that in editing it, windows 8 has broken it.

If I were you, I would just copy and paste the two functions that are in that header file and place them directly in your sketch, and remove the reference to that header file from the top of your sketch.

I will try, but getting it from the two long lines of code might be rather difficult.

Two long lines of code? Oh, of course, windows uses different line endings to the rest of the world.

Easiest if I just paste it here for you then.

// This 39kHz loop from http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino
/* Modulate pin at 39 kHz for give number of microseconds */
void on(int pin, int time) {
  static const int period = 25;
  // found wait_time by measuring with oscilloscope
  static const int wait_time = 9;  

  for (time = time/period; time > 0; time--) {
    digitalWrite(pin, HIGH);
    delayMicroseconds(wait_time);
    digitalWrite(pin, LOW);
    delayMicroseconds(wait_time);
  }
}

void cameraSnap(int pin)
{
  // These Timing are from: http://www.bigmike.it/ircontrol/
  on(pin,2000);
  //This Delay is broken into 3 lines because the delayMicroseconds() is only accurate to 16383. http://arduino.cc/en/Reference/DelayMicroseconds
  delayMicroseconds(7830);
  delayMicroseconds(10000);
  delayMicroseconds(10000);
  on(pin,390);
  delayMicroseconds(1580);
  on(pin,410);
  delayMicroseconds(3580);
  on(pin,400);
}

I have even fixed the indenting, as most of it wasn't.

Thank you so much, it works :D