Arduino Tutorial 07: Matlab

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello Danny Gokey here and welcome to my seventh Arduino tutorial from my Arduino tutorial series today I will talk about my club and how to connect it to the Arduino board using the official matlab's Arduino input/output package first we need to download the MATLAB support for Arduino as known as Arduino input/output package from the official MATLAB website which will enable interaction between the Arduino board and MATLAB the zip file contains installation dot M file PD files with a sketch data needs to be uploaded to the Arduino board Simulink libraries and some examples there are five different sketches that come with the zip file the first sketch enables analog and digital input/output and a basic serial communication the second sketch includes what the first one does plus encoders support the third one includes what the second one does plus server support and the 14 v sketch include what the previous sketch is do + enables Adafruit motor shield version 1 & 2 support the working principle is similar to the one we explained in the previous tutorial for interaction between Arduino and processing we will use the serial port for communication of the Arduino board and a MATLAB that means first we need to upload a sketch to the Arduino board that will work as a server and it put continuously run on the arena and it would listen for commands arriving from the serial port and execute them and if needed a returns an answer in order to install the Arduino input/output package first need to run MATLAB as administrator and set the path to the folder named Arduino IO that came with the zip file now by typing install underscore Arduino in the command window MATLAB will install the Arduino input/output package once we have done this and uploaded one of the sketches to the Arduino board we are ready to make the first example we will make very simple example where we will use a button and a LED and we will make a code that will enable the LED to turn on when the button is pressed we will connect the button to pin number 12 and the LED to pin number 8 okay so first we need to create an Arduino object we did it using this function and here we set our home port number my Arduino port is connected to port 4 and this command will enable interaction between the Arduino board and the MATLAB but B before we continue it's always good to use the clear function so that we are sure that there is nothing in the object from the previous runs ok now on that object we will use the function pin mode to declare the pin number 8 as an output and also the pin number 12 as input okay now I will use the function tick this function starts a stop watch timer I will use this to create a while loop that will last for 10 seconds I will do it like this while and using this tack the top function actually reads the elapsed time from the stopwatch that we have initialized using this tick function so our loop will last for 10 seconds and here in the while loop we will build our code first in a variable B we will read where the button is pressed so we'll have a digital read we will read the pin number 12 where it is pressed and if it's pressed if B is true we will use the digital write function to set the pin number eight to high voltage level and that will turn the LED else the if the button is not pressed the LED will be off okay so there's the code now let's see how it works after we have saved our street we can click on the Run button here we can see that the mock-up is trying to connect to the Arduino board and once the connection is established when I press on the button the LED turns on if you have any questions you can ask them in the comments section and also if you like my videos please subscribe like and share them
Info
Channel: How To Mechatronics
Views: 54,421
Rating: 4.9350181 out of 5
Keywords: Arduino (Brand), MATLAB (Programming Language), Mathematics (Field Of Study), Arduino Tutorial, Tutorial (Media Genre), Arduino IO, Arduino IO Package
Id: n2k_dQRpmfc
Channel Id: undefined
Length: 7min 27sec (447 seconds)
Published: Mon Feb 02 2015
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.