-3
int k ;
int q ;
int f;//pot

void setup() {
  pinMode(k, OUTPUT);
  pinMode(q, OUTPUT);
  pinMode(f, INPUT);
}
void loop() {
  zzf();
}

void gf()
{
  int a = f;//test the conditions of f and store in new variable int a
  if (a == 80)//if a reads 80 then increment a by 1
  {
    ei();//run the ei() function
  }
}

void ei() {
  int k = 3;
  int a = Serial.read();
  {
    digitalWrite(k, a);
  }
}

void zzf() {
  for (f = 0; f < 80; f++) {
    analogWrite(q, f);
  }
}
jai
  • 1
  • 3

1 Answers1

5

Lean the proper C syntax. This is completely wrong:

void gf()
int a = f;//test the conditions of f and store in new variable int a
{

And this is just as wrong for the same reasons:

void ei()
int k = 3
int a = Serial.read();
{digitalWrite(k, a);}
Majenko
  • 105,095
  • 5
  • 79
  • 137
  • 1
    Majenko is right. The { comes after the function name and arguments, not a few lines further on. – Nick Gammon Feb 29 '16 at 19:42
  • @Majenko telling me what i did wrong does not contributes towards the help, the ide debugger already tells me that theres is something wrong and thats what im looking for help on here – jai Feb 29 '16 at 20:38
  • 1
    And I have told you that your syntax is wrong and that you need to learn the right syntax. Look at your code and then look at someone else's code and spot the difference. That way you will learn. – Majenko Feb 29 '16 at 20:41
  • @NickGammon thank you for being helpful, im not sure why this guy just dint lead of with you very simple approach of helping. i did noticed not what i was missing i was stuck on the fact that i had already used those brackets but i failed to see how i forgot to initialize for the function itself – jai Feb 29 '16 at 20:41
  • @Majenko like i said telling me whats wrong is what the ide debugger did, i did not wanted any one to reiterate that but to point to me in detail what i did not understood about the debugger – jai Feb 29 '16 at 20:44
  • @jai This is the first time I'll say that you need to open a C(++) tutorial and start from the beginning and learn what's C(++)'s syntax. I can tell that you need to put { after a function name and (). For example void learnthesyntax(){ <code here> } but it won't help you much without you understanding what's right and why. – Avamander Feb 29 '16 at 20:45
  • updated my original post – jai Feb 29 '16 at 20:56
  • 1
    @jai You've been so busy arguing about the answer that you haven't actually learned anything, have you? Look at your ei() function and tell me what is wrong with it. – Majenko Feb 29 '16 at 20:57
  • If you write "ei()" the compiler sees it as the calling of a function, but the compiler doesn't know where is the function defined, so is say ei' was not declared in this scope. Since compilers are clever they search for the body of the function after "ei()" but it doesn't find the braket: here comes the second error you get expected initializer before 'int. As Majenko said you should learn the syntax, and then learn how to understand the esoteric language of the compiler. I'm still learning so don't worry. – Fra93 Feb 29 '16 at 21:01
  • @Majenko yeah its called cant focus with you bashing on the kid rather then focus on keeping the bashing away from the post and focus on being understanding, but yes thanks for the point out, i just noticed – jai Feb 29 '16 at 21:26
  • @FrAxl93 thanks for the looking out...i just got it to compile, now i gotta learn about using Boolean Op in my conditionals in order to tell if a function is currently being exercise i can have the program do other functions if one of the other functions are being bool as TRUE – jai Feb 29 '16 at 21:31