Pages: [1]   Go Down
Author Topic: Continous Servo Program  (Read 450 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

#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.
Logged

Phoenix, Arizona USA
Offline Offline
Faraday Member
**
Karma: 40
Posts: 5597
Where's the beer?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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).
Logged

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

Arlington, MA, USA
Offline Offline
Sr. Member
****
Karma: 0
Posts: 259
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: