All pins reserved by Arduino servo

조회 수: 11 (최근 30일)
William Zhang
William Zhang 2022년 4월 17일
편집: William Zhang 2022년 4월 19일
clc
clear
triggerPin = 'D2';
echoPin = 'D3';
servoPin = 'D4';
port = 'COM5';
board = 'Nano3';
ledWhite = 'D9';
ledGreen = 'D10';
ledRed = 'D11';
k = 1;
a = arduino(port,board,'Libraries',{'Servo','Ultrasonic'});
configurePin(a,servoPin,'DigitalOutput')
configurePin(a,ledWhite,'DigitalOutput')
configurePin(a,ledRed,'DigitalOutput')
configurePin(a,servoPin,'Servo')
s = servo(a, servoPin, 'MinPulseDuration', 700*10^-6, 'MaxPulseDuration', 2300*10^-6);
Hello everyone,
In the above code snippet, I cannot run all the LED pins because they are all reserved by servo. I have tried configure pin method but this does not work. Could someone please help? Am running MATLAB 2021b.
Error:
"Nano3 Pin D9 is reserved by Servo. To release the resource, clear all variables holding onto this resource."
(Same error for all three pins)
  댓글 수: 2
Walter Roberson
Walter Roberson 2022년 4월 18일
https://www.arduino.cc/reference/en/libraries/servo/ says that pins 9 and 10 are reserved, except 11 and 12 instead for Mega
William Zhang
William Zhang 2022년 4월 19일
Thank you very much! For those students that are wondering by this post in the future, here's all I did:
[Notice how all these pins are repositioned appropriately this time]::
triggerPin = 'D2';
echoPin = 'D3';
servoPin = 'D9';
port = 'COM5';
board = 'Nano3';
ledWhite = 'D5';
ledGreen = 'D6';
ledRed = 'D11';

댓글을 달려면 로그인하십시오.

채택된 답변

William Zhang
William Zhang 2022년 4월 19일
편집: William Zhang 2022년 4월 19일
Heyo everyone, the issue has been resolved thanks to the amazing commentor, Walter Roberson (see comment section).
Here the pins are made new and appropriate to correct pins, where only 9 and 10 are used by servo::
triggerPin = 'D2';
echoPin = 'D3';
servoPin = 'D9';
port = 'COM5';
board = 'Nano3';
ledWhite = 'D5';
ledGreen = 'D6';
ledRed = 'D11';

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by