I was able to compile it once, checked it over, tried to compile once more before saving, and it says “Cannot compile” but doesn’t give a reason. Any ideas?
Its also not compiling, is there any issue with the build IDE or is my code wrong?
Both of these are a simplified version of the “Subscribe” example app.
Have you tried verifying or are you flashing? What happens if you try verifying/flashing for a different device? What happens if you try creating a new app?
Same response, as soon as typed this out, click verify, “Cannot compile”, click again, and it shows an error, then shows “subscribe1.cpp:6:16: error: ‘INPUT_PULLDOWN’ was not declared in this scope
int pb = D6;”
Seems there may be an issue with the Build IDE, I have a forked version of the tinker app, with the only change being
STARTUP(WiFi.selectAntenna(ANT_EXTERNAL));
this is on my current photon, and verified fine about a month ago, and it won’t compile now, all factory forked apps (no changes) compile fine, but if I add any user input at all, it fails.
Hmm, the first code seems to compile for me. The second doesn’t, but it really shouldn’t, so that’s okay.
There are quite a few things wrong with either code, which will definitely not work the way you hoped it to. Try patching those up and give it another go?
Publishing code:
int pb = D6;
bool gateopen = false;
void setup() {
pinMode(pb,INPUT_PULLDOWN);
}
void loop() {
// it doesn't work like this, "pb" == "D6" since that's what you defined it as.
// if you want the value from D6, you're going to have to do a digitalRead
if (pb==HIGH) {
// Nothing is stopping this from publishing infinitely, violating the rate limits
Particle.publish("Jacksonministorpb", "open");
gateopen=true;
}
}
Listening code:
int pb = D6;
// good practice would have a forward declaration/prototype for your handler like this
// void myHandler(const char *event, const char *data); // mark the semicolon, which tells the compiler and implementation WILL follow
void setup() {
pinMode(pb,INPUT_PULLDOWN);
Particle.subscribe("Jacksonministorpb", myHandler);
}
void myHandler(const char *event, const char *data) // this is missing an implementation
{ // which would look like
// add your actual handler code here
}
void loop(){
if (strcmp(data,"open")==0) { // 'data' doesn't exist, so you can't really use that...
digitalWrite(pb,HIGH); // you declared 'pb' as an input, yet you're using it as an output?
delay(2000);
digitalWrite(pb,LOW); // as long as 'data'=='open' this will immediately go high again due to a lacking delay.
}
}
As @Moors7 mentioned, there are definet errors in your code, and I’m sure Particle Build did give you a list of error messages for the second code.
Looking at them - and maybe posting them if you don’t understand them - would be good practice.
Thanks for the replies, like I said, I’m nowhere near a pro at this. I’m still not sure why some of the stock apps fail to compile, but these two are the important ones, I’ll work on it. Thanks again!