I have a question about my sketch.

This is my first time in this field, so I am not sure. Please help.

I sketch the code which is temperature control PID.

I attache whole code, please check my code.

  1. In the middle of section, starting
    float temp_PID::ouput(int &power, int &dir)

there has while loop. I want change while loop to for loop.

I changed

for (int i =0;, i <=9', i++){
sum_temp += input ->readCelsius();
}

but, it didn't work...It says, 'expected primary-expression before ',' token.
Did I miss?

  1. I want to convert the serial data to .csv file. So I copied someone's code.
    It starst with, import processing. serial.*; line.

Here is the problem. It says 'import' does not name a type' did you mean 'qsort'?

and also, under three line, it starts Serial mySerial; section, problem too.

What did I miss?!

Please please check my code seriously. My Prof. said you must finish the code and module in this week.

I have no idea. And I learn arduino and C+ in just one and half months...

TSTC_final_switchingVer_7.ino (12.7 KB)

for (int i =0;, i <=9', i++){

; Not ,

Please use code tags </>

Thanks

  int i = 0;
  float sum_temp = 0.0;
  while(i <=9){
    sum_temp += input->readCelsius();
    i++;
  }

Wow. Whoever wrote that sketch doesn't know that the whole reason to have a 'for' loop is that that form of 'while' loop is both very common and somewhat messy.

The for() loop:

  for (A; B; C)
  {
    // CONTENTS OF THE LOOP
  }

is roughly equivalent to:

  A;
  while(B) 
  {
    // CONTENTS OF THE LOOP
    C;
  }

So to replace the 'while' mess with a 'for' loop, just do the substitutions:

  float sum_temp = 0.0;
  for (int i = 0; i <= 9; i++) 
  {
    sum_temp += input->readCelsius();
  }

You got very close. Somehow an extra "," and an extra "'" got into the line.