Author Topic: Can't compile with particle  (Read 3216 times)

Ncbob

  • Newbie
  • *
  • Posts: 10
Can't compile with particle
« on: May 23, 2016, 09:35:51 pm »
I've installed the latest version of the boards, and I still get an error that Particle is not defined.

I can upload regular sketches without a problem, just not anything with Particle.

I'm running Mac OS X 10.11.4

Arduino 1.6.9 and I've tried it with other versions going back to 1.6.4

PeterF

  • Hero Member
  • *****
  • Posts: 881
Re: Can't compile with particle
« Reply #1 on: May 23, 2016, 11:34:44 pm »
Are you able to copy and paste the actual error message, just in case there is something more there that can help?

And probably a silly question... have you changed the board type from something like the Arduino Uno to the Digistump Oak? And when you mean regular sketches, do you mean ones that don't have things like Particle.publish(), or do you mean sketches for other boards?

Ncbob

  • Newbie
  • *
  • Posts: 10
Re: Can't compile with particle
« Reply #2 on: May 24, 2016, 05:04:38 am »
GarageDoor:1: error : 'Particle' does not name a type

I'm using the digistump oak default board configuration.

And yes, I can compile sketches that do not have Particle references in them and they compile, upload and run on my Oak.

Ncbob

  • Newbie
  • *
  • Posts: 10
Re: Can't compile with particle
« Reply #3 on: May 25, 2016, 08:47:21 pm »
So does anyone know what I can try?

So far I've tried it on several versions of Arduino, three laptops, one with Mac OS X , second with Windows 10, third with Windows 7 and they all do the same thing.

And the Windows 10 is brand new, it's never had Arduino installed on it before.


PeterF

  • Hero Member
  • *****
  • Posts: 881
Re: Can't compile with particle
« Reply #4 on: May 25, 2016, 11:15:19 pm »
Ok, that sounds weird.

Can you trying compiling this code for me and seeing if you get the same error? It was one of the earlier sketches I wrote when getting started with the Particle.publish() stuff, still compiles fine for me now (W10, Arduino 1.6.9, Oak 1.0.1).

Code: [Select]
bool success;

void setup()
{
  success = Particle.publish("setup()");

  //try again
  if (!success)
  {
    Particle.publish("setup()");
  }

  pinMode(1, OUTPUT); //LED on Model A
}

void loop()
{
  success = Particle.publish("loop()");
 
  //try again
  if (!success)
  {
    Particle.publish("loop()");
  }
 
  digitalWrite(1, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);               // wait for a second
  digitalWrite(1, LOW);    // turn the LED off by making the voltage LOW
  delay(100);               // wait for a second
  digitalWrite(1, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);               // wait for a second
  digitalWrite(1, LOW);    // turn the LED off by making the voltage LOW
  delay(100);               // wait for a second

  delay(19600);
}

If that still gives you grief (and the same error message - 'Particle' does not name a type)... All I can suggest is that maybe the board package isn't installed properly? You need to make sure you have gone into the board manager on the Arduino IDE, and installed the "Oak by Digistump" package (and not their Digistump SAM or AVR packages). There are some screenshots and instructions here which may help if you've missed a step or something...

However, if that does work, if you can either post the code you are trying to use, or point to a particular tutorial that is not working for you, maybe we can suss out what is going on...

 

Ncbob

  • Newbie
  • *
  • Posts: 10
Re: Can't compile with particle
« Reply #5 on: May 26, 2016, 04:41:39 am »
Ok so that code compiled.  Here is the code that I can't get to compile:

Code: [Select]
Particle.function("doorSwitch", doorSwitch)
int led;

void setup()
{
   pinMode(10, OUTPUT);
  //Particle.variable("led", led);
}

void loop()
{
 led = 1;
  digitalWrite(10, HIGH);
  delay(500);
  led = 0;
  digitalWrite(10, LOW);
  delay(500);
}

int doorSwitch(String arg)
{

}

I also just downloaded the new boards 1.0.1

I was able to get the variable to work now as well, so now I just can't get this function call to work.

exeng

  • Sr. Member
  • ****
  • Posts: 454
Re: Can't compile with particle
« Reply #6 on: May 26, 2016, 07:37:13 am »
Change you original code as follows... Init led = 0 as a global. Put the Particle.function() call in setup. Should compile but not sure what you want the code to do. Looks like a partial implementation.

Code: [Select]
int led = 0;
void setup()
{
   pinMode(10, OUTPUT);
   Particle.variable("led", led);
   Particle.function("doorSwitch", doorSwitch);

}

void loop()
{
  led = 1;
  digitalWrite(10, HIGH);
  delay(500);
  led = 0;
  digitalWrite(10, LOW);
  delay(500);
}

int doorSwitch(String arg)
{

}

Ncbob

  • Newbie
  • *
  • Posts: 10
Re: Can't compile with particle
« Reply #7 on: May 26, 2016, 02:04:19 pm »
I was testing that it would compile before I had it do anything. 

The tutorial for using Particle.function has it outside any loop or setup, when I moved it inside the setup and added the semi colon it started working.

Thanks for the help

PeterF

  • Hero Member
  • *****
  • Posts: 881
Re: Can't compile with particle
« Reply #8 on: May 27, 2016, 01:23:23 am »
Yeah, any of the calls like Particle.function, Particle.variable belong inside setup, loop or your own custom functions.

Was that example one of the ones from the Oak wiki, or from somewhere else? Just so I know if we need to fix up something on the wiki.

Scratch that: just saw where it was on the wiki... just fixing that up now! Unfortunately you mustn't have seen the example code further down to page showing how it is used in practice, as the bit you copied was just the initial pseudocode showing how it looks, which is why it didn't work.

Glad you got it working!
« Last Edit: May 27, 2016, 01:33:23 am by PeterF »