I'm newbie in C programming and i am trying to drive my arduino, but I found there errors:
sketch_mar05d:84: error: expected constructor, destructor, or type conversion before '=' token
sketch_mar05d:85: error: expected constructor, destructor, or type conversion before '=' token
sketch_mar05d:86: error: expected constructor, destructor, or type conversion before '=' token
sketch_mar05d:87: error: expected constructor, destructor, or type conversion before '=' token
sketch_mar05d:88: error: expected constructor, destructor, or type conversion before '=' token
sketch_mar05d:92: error: expected constructor, destructor, or type conversion before '(' token
sketch_mar05d:93: error: expected constructor, destructor, or type conversion before '(' token
sketch_mar05d:94: error: expected constructor, destructor, or type conversion before '(' token
sketch_mar05d:97: error: expected unqualified-id before 'for'
sketch_mar05d:97: error: expected constructor, destructor, or type conversion before '>' token
sketch_mar05d:97: error: expected constructor, destructor, or type conversion before '--' token
I haven't seen Gosub used in many many years and not in Arduino so I can't tell what might be wrong there except that they simply might not work in v1.0 I did notice you use if/endif instead of if { }. I'm not sure if this syntax works in the IDE or not. In traditional C if loops, an equal to comparison is done with a double ==. This may or may not be causing problems as well since I am unfamiliar with using a VB style if/end if syntax in the arduino IDE.
Every one of the errors you are getting are related to a syntax error where you have fumble fingered something or left out something. Fix those 3 and see if it starts to shorten your list.
Did you copy this code from somewhere or write it yourself?
I only ask because this is A LOT of code to not have built many times to catch these types of errors in pieces instead of catching all the errors in one build which makes it much more difficult to track down the problems.
To Sacman:
I write it by myself, by using the logic from my supervisor final project. I thought he used C language.
To Nick Gammon:
Oh thank you finally I know this is Basic, heu
To All:
Every arduino program, I have found that they use void(), it means it has no return value.
One reason why I force to use GoSub is because it has return value, and in my complicated program, I need to return..
Do you have any idea what syntax I can use in order to have return value?
creativen:
To All:
Every arduino program, I have found that they use void(), it means it has no return value.
One reason why I force to use GoSub is because it has return value, and in my complicated program, I need to return..
Better start studying C++, I think. The Arduino IDE uses C++ (not C). Also only void functions return no value. To return a value you put some other word (like int) in place of void. eg.
int foo ()
{
return 42;
}
In any case, functions return, whether or not they return a value.
heuu, well I must start from beginning again for C++
Thank you all very very very very much, at least now I know where I should go rather than stay fixing crazy code now.
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
return 0;
}
Then it show this:
sketch_mar05a.cpp:1:20: error: iostream: No such file or directory
sketch_mar05a.cpp: In function 'int main()':
sketch_mar05a:5: error: 'cout' was not declared in this scope
is it C or C++?or is there any wrong with the compiler?
Right. Well these examples assume you are running on a Unix or similar system where you have stdin and stdout. (That is, in effect, the keyboard and the screen). Since you don't have a keyboard or screen on the Arduino you have hit a problem.
Try looking at some of the example sketches in the IDE. For one thing, they "predefine" main for you, so even using main is a no-no.
Hmm, both codes you gave me is much different for newbie like me...
I think to save time, can I just directly learn the pattern for the IDE rather than C++ then convert to IDE C++...?
Hmmm, where I can learn C++ for Arduino IDE?
I'm so sorry coz I ask too many...
I think to save time, can I just directly learn the pattern for the IDE rather than C++ then convert to IDE C++...?
I'm struggling to pick the meaning out of that sentence.
The IDE (Integrated Development Environment) is just a way of editing, compiling and downloading Arduino sketches, which are simply sawn-off C++ programs.