Go Down

Topic: Coding problem (Read 20 times) previous topic - next topic

OsmanRozac

Jun 26, 2019, 09:52 am Last Edit: Jun 26, 2019, 10:00 am by OsmanRozac
i was trying to code Arduino Nano to control servo motor using IR Sensor. my code is as follows


#include <Servo.MG996R>

int sensor_pin=7;
int tap_servo_pin=6;
int val;

void setup() {
 pinMode(sensor_pin. INPUT),
 tap_servo.attach(tap_servo_pin);
}

void loop() {
   val= digitalRead(sensor_pin);
   if (val=0)
   (tap_sensor.write(0));
   
   if (val=1)
   (tap_servo.write(85))
}

The project is to create self controlled tap, a tap that will recognize hand and then turn, when the hand is no longer there then return back to its position.

the following error were shown when i try compiling it

/tmp/497281337/Self_Controlled_Water_Tap/Self_Controlled_Water_Tap.ino:1:24: fatal error: Servo.MG996R: No such file or directory

#include <Servo.MG996R>

int sensor_pin=7;
int tap_servo_pin=6;
int val;

void setup() {
 pinMode(sensor_pin. INPUT),
 tap_servo.attach(tap_servo_pin);
}

void loop() {
 val= digitalRead(sensor_pin);
 if (val=0)
 (tap_sensor.write(0));
 
 if (val=1)
 (tap_servo.write(85))
}

^

compilation terminated.

exit status 1

pert

It seems like you're trying to use some library for the servo, but you have not used the correct filename for the library in your #include directive:
Code: [Select]
#include <Servo.MG996R>
You will find a demonstration of the correct use of the library in the example sketches that come with the library. Please study them and update your sketch accordingly.

After that, if you're still having problems, come back here with either a link to the library you're using or the full library name as displayed in the Arduino IDE's Library Manager.

Go Up