I get this error when compile:
"ex.cpp: In function ‘void forward(int, int)’:
ex.cpp:8: error: ‘analogWrite’ was not declared in this scope"
What should I include to make it work?
I tried Arduino.h, but it gives me another error:
"arduino-1.5.6-r2/hardware/arduino/avr/cores/arduino/main.cpp:30: undefined reference to `setup'"
Yeah, I tried that.
Get this error:
"main.cpp.o: In function main': arduino-1.5.6-r2/hardware/arduino/avr/cores/arduino/main.cpp:30: undefined reference to setup'
arduino-1.5.6-r2/hardware/arduino/avr/cores/arduino/main.cpp:33: undefined reference to `loop'"
shamdor:
Can you look at the code I provided and say what is wrong?
The code you posted does not #include Arduino.h, which is why you get errors when you have calls to Arduino functions.
If you think you have fixed that and still get errors and want suggestions on how to fix them, you need to post your updated code. I'm not going to speculate about code you haven't posted.
PeterH:
If you think you have fixed that and still get errors and want suggestions on how to fix them, you need to post your updated code. I'm not going to speculate about code you haven't posted.
Modified code:
main.imo contains
#include "ex.h"
void setup()
{
// Some init here
}
void loop()
{}
Now I get this errors:
main.cpp.o: In function main': arduino-1.5.6-r2/hardware/arduino/avr/cores/arduino/main.cpp:30: undefined reference to setup'
arduino-1.5.6-r2/hardware/arduino/avr/cores/arduino/main.cpp:33: undefined reference to `loop'
The code you posted compiles fine for me, with the sketch saved in a .ino file. I don't know whether .imo is a typo in your post, but if that's the actual file name you're using that is wrong.