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!