I am currently clueless.
After struggling with an ISR ft. a series of 74HC595 Shift Registers (which do work now ;D) I am stuck at implementing a piece of code that triggers 4 individual servo's.
The code I have is working when I use it independently;
#include <Servo.h>
Servo rechtsvoor;
Servo linksvoor;
Servo rechtsachter;
Servo linksachter;
int poslinksvoor = 80; // variable to store the servo position
int posrechtsvoor = 165;
int poslinksachter = 130;
int posrechtsachter = 10;
int i = 0;
int initial = 0;
void setup() {
rechtsvoor.attach(3); //rechtsvoor
linksvoor.attach(5); // rechtsachter
rechtsachter.attach(6); // rechtsachter
linksachter.attach(9); // linksachter
}
void loop()
{
if(initial==0){
linksachter.write(poslinksachter); // lager is de goede richting op
rechtsvoor.write(posrechtsvoor); // lager is de goede richting op
linksvoor.write(poslinksvoor); // hoger is de goede richting op
rechtsachter.write(posrechtsachter); // hoger is de goede richting
delay(10);
}
initial = 1;
}
}
The code basically 'normalizes' the servo's for the application I am building (I have some functions ready that simply rotate the servo between certain values (80-150 for instance), but I left these away in the code above to keep it more clear and to have a better overview for you!
So this works, but when I implement this in my code for my leds (a long boring ISR / shift routine code) it simply doesn't work. The code verifies and works (the leds still fade etc.) but the servo's don't act at all.
It seems that the code/arduino simply skips the whole servo-piece at all.
Anyone got any idea's? I'm kinda out. Is it possible that because all of my variables and pins are '#define'-ed in my code that the simple Servo linksachter; doesn't work anymore?
How do you '#define' a servo anyway?
Hope that you can help me! I have an Duemilanove /w atmel 168