system
1
#include <Servo.h>
Servo myservo;
int pin= 11; // input pin
int ledpin;
int val=0;
void setup()
{
myservo.attach(11);
pinMode(pin, INPUT);
digitalWrite(pin, HIGH);
pinMode(ledpin, OUTPUT);
digitalWrite(ledpin, HIGH); // high for ON, low for OFF
}
void loop()
{
if (pin== HIGH){
myservo.write(180);
}
else
{myservo.write(0);
}
}
I am using this code to run a servo but i am not able to. How can I amplify the signals I am getting from the pin 11.
cr0sh
2
You're checking "pin" to be HIGH, but you're not reading it anywhere in the loop...
system
3
void loop()
{
if (pin== HIGH){
myservo.write(180);
}
else
{myservo.write(0);
}
}
servo will rotate once the pin is HIGH
system
4
"pin" has the value 11.
It can never be == 1.
int pin= 11; // input pin
int ledpin;
int val=0;
void setup()
{
myservo.attach(11);
pinMode(pin, INPUT);
digitalWrite(pin, HIGH);
pinMode(ledpin, OUTPUT);
You've attached a servo to pin 11, and you're using it as an input.
Good luck with that.
BTW, I answered a very similar question to this the other day: