hello, i wrote a sketch shown bellow. basically when i press a button, position of servo changes and LED will indicate the position. however, the LED seems really dim. but when i upload a sketch,the LED which i connect to PIN 13, blinks brightly. is there a problem with my sketch that makes the LED not as bright?
#include <Servo.h>
Servo myservo;
int Red = 13;
int Green = 12;
const int buttonPin = 2;
int buttonState = 0;
void setup() {
myservo.attach(7);
myservo.write(90);
pinMode(buttonPin, INPUT_PULLUP);
}
void loop()
{
buttonState = digitalRead(buttonPin);
if (buttonState == LOW) {
myservo.write(175);
digitalWrite(Green, HIGH);
digitalWrite(Red, LOW);
}
else
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
myservo.write(90);
digitalWrite(Green, LOW);
digitalWrite(Red, HIGH);
}
}
thanks for the advice