5 Replies - 323 Views - Last Post: 27 February 2018 - 10:20 PM Rate Topic: -----

#1 AussieNinja   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 25-February 18

Error " expected Primary-Expression" before "const" an

Posted 25 February 2018 - 04:19 AM

hello,
I am having trouble with this code and would love it if some one would point out all of my flaws :)/>/>
i have googled a "primary expression" and i couldn't find out what to put there.


Code

int D = A4;
int val = 0;
const char *eventName = "Pressure";
int  data = val;
void setup() {

}

void loop() {
    val = analogRead(D)/25-20;
delay(100);
Particle.publish(const char *eventName const char data);
Particle.publish(String eventName String data);

}


P.S. it is hopefully going to be for measuring pressure from a tank and displaying its percentage of "fullness" :)/>/>
Thankyou So Much in advance
AussieNinja

This post has been edited by ndc85430: 25 February 2018 - 04:22 AM
Reason for edit:: Fixed code tags.


Is This A Good Question/Topic? 0
  • +

Replies To: Error " expected Primary-Expression" before "const" an

#2 ndc85430   User is offline

  • I think you'll find it's "Dr"
  • member icon

Reputation: 825
  • Posts: 3,337
  • Joined: 13-June 14

Re: Error " expected Primary-Expression" before "const" an

Posted 25 February 2018 - 04:25 AM

I take it that the errors are coming from the last two lines of the code you've posted? For future reference, please post the error message in its entirety, since it gives important information (like the line number). You don't put the types of the arguments when you call a function and you also need to put commas between the arguments. Perhaps you need to go and study functions again?

Also, the code tags in your post were broken. You should just use the "CODE" button in the editor to insert the pair of opening and closing tags and then just paste your code between them.
Was This Post Helpful? 0
  • +
  • -

#3 AussieNinja   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 25-February 18

Re: Error " expected Primary-Expression" before "const" an

Posted 26 February 2018 - 05:29 PM

Thankyou so much, i haven't done any coding lessons and this is just a hobby project :)
Thanks once again,
AussieNinja
Was This Post Helpful? 0
  • +
  • -

#4 ndc85430   User is offline

  • I think you'll find it's "Dr"
  • member icon

Reputation: 825
  • Posts: 3,337
  • Joined: 13-June 14

Re: Error " expected Primary-Expression" before "const" an

Posted 26 February 2018 - 11:31 PM

How are you learning the language then? Any decent material should be teaching you these things.
Was This Post Helpful? 0
  • +
  • -

#5 AussieNinja   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 25-February 18

Re: Error " expected Primary-Expression" before "const" an

Posted 27 February 2018 - 01:59 PM

At the moment I am learning just by reading
Watching "How to's" on YouTube but I would like to do some more coding so is there any
Programs/courses you would suggest???
Was This Post Helpful? 0
  • +
  • -

#6 ndc85430   User is offline

  • I think you'll find it's "Dr"
  • member icon

Reputation: 825
  • Posts: 3,337
  • Joined: 13-June 14

Re: Error " expected Primary-Expression" before "const" an

Posted 27 February 2018 - 10:20 PM

Really, get a book on the language and work through it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1