Error compiling locally [SOLVED]

HI I just tried to implement the shiny new code that Zach posted “Controlling the connection”.

I can compile it and get it to work in the cloud IDE. (Did need to declare D0 as an input).

But when I paste this same code for a local compile I get lots of errors.

…/src/application.cpp: In function ‘void setup()’:
…/src/application.cpp:5:11: error: ‘D7’ was not declared in this scope
pinMode(D7, OUTPUT);
^
…/src/application.cpp:5:15: error: ‘OUTPUT’ was not declared in this scope
pinMode(D7, OUTPUT);
^
…/src/application.cpp:5:21: error: ‘pinMode’ was not declared in this scope
pinMode(D7, OUTPUT);
^
…/src/application.cpp:6:19: error: ‘D0’ was not declared in this scope
attachInterrupt(D0, connect, FALLING);
^
…/src/application.cpp:6:23: error: ‘connect’ was not declared in this scope
attachInterrupt(D0, connect, FALLING);
^
…/src/application.cpp:6:32: error: ‘FALLING’ was not declared in this scope
attachInterrupt(D0, connect, FALLING);
^
…/src/application.cpp:6:39: error: ‘attachInterrupt’ was not declared in this scope
attachInterrupt(D0, connect, FALLING);
^
…/src/application.cpp: In function ‘void loop()’:
…/src/application.cpp:10:16: error: ‘D7’ was not declared in this scope
digitalWrite(D7, HIGH);
^
…/src/application.cpp:10:20: error: ‘HIGH’ was not declared in this scope
digitalWrite(D7, HIGH);
^
…/src/application.cpp:10:24: error: ‘digitalWrite’ was not declared in this scope
digitalWrite(D7, HIGH);
^
…/src/application.cpp:11:12: error: ‘delay’ was not declared in this scope
delay(500);
^
…/src/application.cpp:12:20: error: ‘LOW’ was not declared in this scope
digitalWrite(D7, LOW);
^
…/src/application.cpp: In function ‘void connect()’:
…/src/application.cpp:17:7: error: ‘Spark’ was not declared in this scope
if (Spark.connected() == false) {

I have updated my cli env using the command line npm update -g spark-cli

Looks like I am missing an include or something basic since the compile is complaining profusly.

Here’s my code:

SYSTEM_MODE(SEMI_AUTOMATIC);
void setup() {
pinMode(D7, OUTPUT);
pinMode(D6,OUTPUT);
pinMode(D0,INPUT);
attachInterrupt(D0, connect, FALLING);
}
void loop() {
digitalWrite(D6,LOW);
digitalWrite(D7, HIGH);
delay(500);
digitalWrite(D7, LOW);
delay(500);
}
void connect() {
digitalWrite(D6,HIGH);
if (Spark.connected() == false) {

Spark.connect();

}
}
}**

do you have

#include "application.h"

at the top of the file? It’s automatically added by the Online IDE if not present, but when compiling locally using the makefile you have to add this yourself.

I do. Got left out on the cut paste. Here the top of the program.

For some reason the font is supper sized automagically!


#include "application.h"

SYSTEM_MODE(SEMI_AUTOMATIC);


void setup() {
  pinMode(D7, OUTPUT);
  pinMode(D6, OUTPUT);
  pinMode(D0, INPUT);
  attachInterrupt(D0, connect, FALLING);
}

Here’s my latest compile as a screen shot.

From this you can see the issue is with last agr in the attachInterrupt().

I have loaded the latest from Git. I see the typedef in the spark_wiriing_interrupt.h file.

Any ideas?

I would change the name ‘connect’ to something else. That name is already defined (with a deprecation error) in spark_wiring_network.h

fyi, but this has nothing to do with SYSTEM_MODE, so the title is a bit misleading. Also your pasted code has FALLING as the last argument to attachInterrupt() but in the compile screenshot I see CHANGE as the last parameter.

But that’s not the issue - the problem is with the second parameter connect, but I don’t see that in your pasted code.

There’s a number of issues with your report here that will make tracing the problem harder than it needs to be. When reporting issues please take time to make sure your report is complete and accurate, that makes the best use of everyone’s time. Ok :slight_smile:

I agree.

I just declared the connect before the calling in the interrupt and it compiled.

Here’s my code snippet.

#include “application.h”

SYSTEM_MODE(SEMI_AUTOMATIC);

// Added this next line to forward declare connect().
void connect();

void setup() {
pinMode(D7, OUTPUT);
pinMode(D6, OUTPUT);
pinMode(D0, INPUT);
//attachInterrupt(D0, connect, FALLING);
attachInterrupt(D0, connect, CHANGE);
}

void loop() {
digitalWrite(D6,LOW); // Go lou unit an interrupt occurs
digitalWrite(D7, HIGH);
delay(500);
digitalWrite(D7, LOW);
delay(500);
}

void connect() {
digitalWrite(D6,HIGH);
if (Spark.connected() == false) {
Spark.connect();
}
}

Thanks for taking a look all. Extra eye always help.

chipMonk

1 Like

Great to hear you got it resolved :slight_smile: I changed the title to more closely reflect the issue.

2 Likes