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();
}
}
}**