Go Down

Topic: Continous Servo Program (Read 473 times) previous topic - next topic

barkbarks86

#include <Servo.h>
int main()
{
  Servo blue;
}

void setup()
{
  blue.attach(9);
  blue.write(180);
}

void loop() {
}

Why is the program kirking out?
Error message: blue was not declared in this scope.

cr0sh

Drop the main(), put the declation of Servo in setup() - basically, the error message is telling you it knows nothing about the Servo declaration in main() (which I am sure is overwritten anyhow by the IDE - main() is built for you behind the scenes).
I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

tastewar

The way you've written it, blue is a local variable in the main function. You probably want to declare it in the global scope, outside of any function.

Go Up