Compilation error: 'Serial' does not name a type

I am getting the following compile errors. What am I doing wrong?
THANKS!

 Servo

C:\Users\Japper\Documents\Arduino\mindflexservo\mindflexservo.ino:52:3: error: expected '}' at end of input
}
^

exit status 1

Compilation error: 'Serial' does not name a type

code:

#include <Brain.h>
#include <Servo.h>

//////////////////////////
// mindflexservo
////////////////////////??
  Serial.begin(9600);
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);



void loop() {  // Expect packets about once per second.
  // The .readCSV() function returns a string (well, char*) listing
  //the most recent brain data, in the following format:
  // "signal strength, attention, meditation, delta, theta, low 			// alpha, high alpha, low beta,  high beta, low gamma, 			// high gamma"

  if (brain.update()) {

    // Serial.println(brain.readErrors());
    // Serial.println(brain.readCSV());
    //sprintf(a, "%c",brain.readCSV());

    a = brain.readCSV();

    v = a.indexOf(',');
    v = a.indexOf(',', v + 1);
    v = a.indexOf(',', v + 1);
    v = a.indexOf(',', v + 1);
    z = a.indexOf(',', v + 1);

    a1 = a.substring(v + 1, z);
    num = a1.toInt();
    v = a.indexOf(',', z + 1);

    a = a.substring(z + 1, v);

    num1 = a.toInt();
    Serial.print("alpha =  ");
    Serial.println(num1);

    output = map(num, 0, 999999, 0, 180);

    myservo.write(output);  // tell servo to go to position in variable 'pos'

    delay(15);

    // analogWrite(12,output);

    //brain.readCS).toCharArray(a,200);
  }

All of the above needs to be in a function, setup().

Also you need to declare instances of Servo and Brain objects. Look at the examples that come with those libraries to see how. It will look something like:
Servo myServo;

Variable declarations are missing for v, a, num1, output, at least.

Also, I think that you are missing a closing curly bracket (}) to close the loop() function. Curly brackets must match.

There probably is more.

Hi,
Can I suggest you go and look at any of the Servo library examples in the IDE, to get the correct structure of driving a servo?

Tom.. :smiley: :+1: :coffee: :australia:

Hi,
This thread is about the same subject as this one:

?

If so, ask a moderate to join the 2 threads and avoid wasting time on repetitive threads.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.