Library 'Servo' is not uploaded to the board ERROR

2 vues (au cours des 30 derniers jours)
Andi
Andi le 7 Déc 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-
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 my code
a=arduino();
s1 = servo(a, 'D9', 'MinPulseDuration', 700*10^-6, 'MaxPulseDuration', 2300*10^-6);
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

Réponses (1)

James Bittner
James Bittner le 12 Jan 2024
When you go to connect to the arduino you will need to request any libraries that you will be utilizing.
Two ways to achieve this:
or
-run the
>>arduinosetup
command and select the 'Servo' library when you initially program the board in the GUI

Catégories

En savoir plus sur Arduino Hardware dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by