Particle Dev and Build on Web

With my Core tray to exercise with the attached code. If I’m flashing with the build from your Web page the code working and led D7 is blinking. If I flashing with Particle Dev on my pc dosen’t work. Are there a reason?
Thanks a lot Vale

Code is not building from me but copy in internet:

const int buttonPin = D4;     // the number of the pushbutton pin
const int ledPin =  D7;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
   // initialize the LED pin as an output:
   pinMode(ledPin, OUTPUT);
   // initialize the pushbutton pin as an input:
   pinMode(buttonPin, INPUT);
}

void loop() {
   // read the state of the pushbutton value:
   buttonState = digitalRead(buttonPin);

   // check if the pushbutton is pressed.
   // if it is, the buttonState is HIGH:
   if (buttonState == HIGH) {
     // turn LED on:
     digitalWrite(ledPin, HIGH);
   } else {
     // turn LED off:
     digitalWrite(ledPin, LOW);
   }
}

Hi , you need to add a include , which from memory is #include"application.h"

You need #include "application.h" if you’ve named your main file as .CPP.
If you named it - as Web IDE does - .INO the preprocessor will take care of this and the prototyping of your functions - if needed.

And you might want to change pinMode(buttonPin, INPUT); to pinMode(buttonPin, INPUT_PULLUP); if your button is connecting D4 to GND or pinMode(buttonPin, INPUT_PULLDOWN); if your button is between D4 and 3V3.

And just as a side note, what you are doing in loop() is shorter written like this :wink:

void loop()
{
  digitalWrite(ledPin, digitalRead(buttonPin));
}

But for proper use of buttons, you might need to debounce the button.

Thanks for your answer

  1. the application.h I should download and have in directory? After this change I receive a msg Particle Dev tell me my version is to old:
  2. I’m using Shield Shield v2.0.1 but on the core D4 I don’t have a signal is some problems with shield shield and Digital input?
    Remark if I use a breadboard with the same core and the same program it work fine.
    Thanks Vale

No you don’t need to download the application.h. It’s an intrinsic part of the Particle framework.
Actually Particle Dev uploads your code to the Particle build farm where it will be combined with the framework and compiled.

About the shield I can’t say a lot - haven’t played with it yet :wink: