How to control DC motor with Elegoo mega2560 board and adafruit motorshield V1?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Prateek
le 22 Nov 2022
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 commentaires
Voir également
Catégories
En savoir plus sur Arduino Hardware dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!