In this project we are going to control brightness of LED connected to digital pin of Arduino by creating a simple GUI on Matlab. We will have to type voltage value, we want across LED on edit box.
Welcome to the third tutorial or tutorial no. 1.2 of the course “using MATLAB GUI with Arduino support package”.Click here TUTORIAL 1.1 to read previous tutorial.
Watch the video version of this project for better understanding:
1. First of all create this GUI in Blank GUI and then run it.(How to create GUI on Matlab)
2. Double click on PushButton to change its properties
For PushButton: String Name=”FIRE” ; Tag Name=”FIRE”
3. Double click on EditText Box to change its properties
For EditText Box: String Name=” ” ; Tag Name=”writePWMvalue”
4. Click on Run, GUI looks like this:
5.Now under Opening function type these commands:
clear all;
global a;
a= arduino(‘COM3’);
6.Under function FIRE type:
x= str2num(get(handles.writePWMvalue,’string’));
writePWMvoltage(a,10,x);
NOTE: Codes are explained in detail in the above video ^.
7. SETUP:
8. Click on Run:
9. Type different values on EditBox (max 5v), and hit FIRE!
- For .2volts
- For 2volts
- For 5volts