hello,
I'm sure that my problem is really a beginner problem,...but I'm actually a beginner ;)..
so, I want to control a servo with a sharp IR, I want the servo to turn in a sense if I'm approaching the sensor, and in the other sense if I'm not approaching the sensor... I'm actually able to do it, but I can't control the speed with this code below , I think there is something to do with an increment operator, but I'm not able to do it
thank you
#include <Servo.h>
#define IR_pin 0
Servo myservo1;int pos = 0;
int IR_val = 0;
void setup()
{
Serial.begin(9600);
myservo1.attach(2);}
void loop()
{IR_val = analogRead(IR_pin);
Serial.println( IR_val);if (IR_val < 200)
{
myservo1.write(180);
delay(30);
}if (IR_val > 200)
{myservo1.write(0);
delay(30);
}
Serial.println( IR_val);}