How to control DC motor with Elegoo mega2560 board and adafruit motorshield V1?
7 次查看(过去 30 天)
显示 更早的评论
Hello,
I just bought an Elegoo Mega2560 board and an Adafruit motorshield V1. I need to control a DC motor, and I did a code like below. The code ran fine and said that the motor is running, but my motor is not running at all. Could anybody please help?
%% Create shield object
% Create an arduino object & include the Adafruit\MotorShieldV2 library to the hardware
a = arduino('COM3','MEGA2560','Libraries','Adafruit\MotorShieldV2')
% Create an add-on shield object by specifying the required library name parameter
shield = addon(a,'Adafruit\MotorShieldV2')
% Create a DC motor object at port 3
dcm3 = dcmotor(shield,3)
start(dcm3)
dcm3.Speed = 0.3 % Set the motor speed to 0.3
pause(2)
stop(dcm3)
clear dcm shield a
0 个评论
回答(1 个)
Prateek
2022-11-22
Hi Hannah,
The code shared by you is for Adafruit Motorshield V2 but it seems you’re using Adafruit Motorshield V1. Please note that the V1 has been discontinued for a while and hence not supported by MATLAB.
In case you want to use V1 only, here is a link with instructions on how to create custom support for hardware: Create Custom Arduino Add-On Device, Library, or Code - MATLAB & Simulink - MathWorks India
Hope this helps.
Regards,
Prateek
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Arduino Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!