Hi,
I am having a weird issue.
I was trying to fade a LED in a bigger project, and every time I tried fading the LED it would turn green, and then keep being green until the green channel on the led was set to zero.
I used hours trying to debug my code, and I would not figure out what was wrong. I then tried a simpler code that only controlled the RGB LED, and that worked, so eventually I figured out that if I attack my servo this issued occurs. I this a bug in the development tool or what is going on?
I am using version 1.7.10 for Liux 64 bit downloaded from arduino.org.
This is my test code.
#include <Servo.h>
// Pin Definitions
const int servoPin = 3;
const int blueLedPin = 9;
const int redLedPin = 10;
const int greenLedPin = 11;
// Servo Definition
Servo servoMotor;
void setup() {
pinMode(greenLedPin, OUTPUT);
pinMode(redLedPin, OUTPUT);
pinMode(blueLedPin, OUTPUT);
//servoMotor.attach(servoPin);
}
void loop() {
for(int i=255; i > 0 ; i -= 1) {
analogWrite(blueLedPin, i);
analogWrite(greenLedPin, i);
analogWrite(redLedPin, i);
delay(7);
}
for(int i=0; i < 255 ; i += 1) {
analogWrite(redLedPin, i);
delay(7);
}
delay(10000);
}
If you uncomment the servoMotor.attach line it will instead of fading out and then fading to red it will instantly turn Green, and the power off, and the fade to red.