Go Down

Topic: Newb Here! Tons of questions (Read 512 times) previous topic - next topic

offy

First off, hello all, im new here.

All questions are on Ubuntu 8.10

1. Error Building libary "Stepper"

2. Will this code be correct to just make a servo move to test it?

Code: [Select]
// Sweep
// by BARRAGAN <HIS SITE HERE>

#include <Servo.h>

Servo myservo;  // create servo object to control a servo

int pos = 0;    // variable to store the servo position

void setup()
{
 myservo.attach(0);  // attaches the servo on pin 9 to the servo object
}

void loop()
{
 for(pos = 0; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees
 {                                  // in steps of 1 degree
   myservo.write(pos);              // tell servo to go to position in variable 'pos'
   delay(15);                       // waits 15ms for the servo to reach the position
 }
 for(pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees
 {                                
   myservo.write(pos);              // tell servo to go to position in variable 'pos'
   delay(15);                       // waits 15ms for the servo to reach the position
 }
}



halley

(1) What IS the error you got when you tried to build the "Stepper" library?  How did you attempt to build the library?

(2) [font=Courier]myservo.attach([glow]0[/glow]); // attaches the servo on pin [glow]9[/glow] to the servo objects[/font]

Attaching things to pin 0 will make it hard to use the serial port, and I think the default library only supports pins 9 and 10.

offy

That is my old code, I changed it to 9. Also I didn't do anything. I opened up the program for the first time, put the code in and attempted to add that servo code to my microcontroller and got the stepper error.

Go Up