Use Matlab programming and the Arduino board with one RGB LED and three resistor
ID: 2082831 • Letter: U
Question
Use Matlab programming and the Arduino board with one RGB LED and three resistors (330 Ohm for instance) to generate different colors. Your program MUST prompt the user to enter 3 numbers in the range 0-255 and then display the corresponding color in the LED. Your program MUST also allow the user to START OVER as often he she wishes. WITHOUT THE NEED to rerun the program. The Table below lists the decimal value for few selected colon. In this Table the decimal 255 corresponds to the maximum voltage applied to the LED (for example 5V corresponds to the decimal 255 and 0V corresponds to decimal 0). You MUST upload on Blackboard two files: The Matlab file used to run your Arduino board. A short movie (using your smartphone) demonstrating your experiment.Explanation / Answer
You need to install the Arduino support packages in MATLAB and then connect your Arduino board with the PC. After this you can run the below MATLAB script and see the results.
I assume you are connecting the RGB leds on pins no. 9, 10, 11 respectively.
----------------------------------------------------
% Script to run RGB led on Arduino from MATLAB
% create an Arduino object
A = arduino()
% pass the three colours to MATLAB
red = input('Enter the red value in 0-255');
green = input('Enter the green value in 0-255');
blue = input('Enter the blue value in 0-255');
% generate the colours
writeDigitalPin(a, 'D9', red);
writeDigitalPin (a,'D10', green);
writeDigitalPin (a,'D11', blue);
pause(5); % 5 sec wait
% Stop communication with Arduino
clear a;
-------------------
Let me know your feedback on the same.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.