Library 'Servo' is not uploaded to the board ERROR help

6 visualizaciones (últimos 30 días)
Andi
Andi el 7 de Dic. de 2023
Respondida: Vidip el 27 de Dic. de 2023
I keep getting this error message when trying to run my code, I'm confident my wiring is correct and I do not know what this error means-
Error message: Library 'Servo' is not uploaded to the board. Clear the current Arduino object and recreate it to include the appropriate library. For a list of available libraries, type 'listArduinoLibraries'.
Here is the code
clear
clc
a=arduino();
s1 = servo(a, 'D9', 'MinPulseDuration', 700*10^-6, 'MaxPulseDuration', 2300*10^-6);
arduino requires MATLAB Support Package for Arduino Hardware.
writePosition(s1,0);
userResponse = "yes";
while userResponse == "yes"
chicken = input("Insert your resistor");
voltage = readVoltage(a, "A0");
if voltage < 1.67155
resistor = "47k";
writePosition(s1,0.25);
minR = 47000 * 0.95;
maxR = 47000 * 1.05;
elseif voltage < 3.53128
resistor = "10k";
writePosition(s1,0.5);
minR = 10000 * 0.95;
maxR = 10000 * 1.05;
elseif voltage < 4.69941
resistor = "1k";
writePosition(s1,0.75);
minR = 1000 * 0.95;
maxR = 1000 * 1.05;
else
resistor = "330";
writePosition(s1,1);
minR = 330 * 0.95;
maxR = 330 * 1.05;
end
resistance = voltageToResistance(voltage);
withinTolerance = (resistance >= minR && resistance <= maxR);
disp(resistor)
if withinTolerance == 1
writeDigitalPin(a, "D4", 1);
writeDigitalPin(a, "D5", 0);
%disp("green")
else
writeDigitalPin(a, "D4", 0);
writeDigitalPin(a, "D5", 1);
%disp("Red")
end
userResponse = input("Would you like to check another resistor? ","s");
writePosition(s1,0);
writeDigitalPin(a, "D4", 0);
writeDigitalPin(a, "D5", 0);
end

Respuestas (1)

Vidip
Vidip el 27 de Dic. de 2023
I understand that you are getting the error message- ‘Library 'Servo' is not uploaded to the board. Clear the current Arduino object and recreate it to include the appropriate library. For a list of available libraries, type 'listArduinoLibraries' whenever you try to run the code.
The error message indicates that the 'Servo' library is not uploaded to the Arduino board. To resolve this issue, you can clear the current Arduino object and recreate it to include the appropriate library. And to create servo object and calibrate the motor, you can either create an arduino object and include the Servo library or, you can explicitly specify it in the Libraries Name-Value pair at creation of arduino object.
You can follow this below documentation to properly create servo object and calibrate the motor-

Categorías

Más información sobre Run on Target Hardware en Help Center y File Exchange.

Productos


Versión

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by