Servo Operation
One Second Oscillations
10 Seconds Oscillations
//////// ARDUINO
///////code by V. SaiKiran.......https://www.facebook.com/saikiran27
void setup()
{
pinMode(A0,INPUT);
pinMode(A2,INPUT);
pinMode(9,OUTPUT);
pinMode(11,OUTPUT);
pinMode(13,OUTPUT);
digitalWrite(9,LOW);
digitalWrite(11,LOW);
Serial.begin(9600);
}int x=0;
int y=0;
void loop()
{
int val;
int ref;
int valm;
int refm;
val=analogRead(A2);
valm=map(val,0,1023,0,100);
//Serial.println(val);
Serial.println(valm);
//Serial.println(x);
//Serial.println(y);
ref=analogRead(A0);
refm=map(ref,0,1023,0,100);
Serial.println(refm);
//delay(10);
if((valm)>(refm+3))
{
digitalWrite(9,HIGH);
x=valm-refm;
delay(10);
// delay(map(x,0,30,1,5));
digitalWrite(9,LOW);
}
else
{
//delay(10);
if((valm)<(refm-3))
{
digitalWrite(11,HIGH);
y=refm-valm;
delay(10);
//delay(map(y,0,30,1,5));
digitalWrite(11,LOW);
}
}
}
No comments:
Post a Comment