Please, solve the following programming problem using MATLAB. Comment for which
ID: 3920311 • Letter: P
Question
Please, solve the following programming problem using MATLAB. Comment for which portion of code does what will be very much appreciated.
The seven-segment LED (Light Emitting Diode) or LCD (Liquid Crystal Display) type displays, provide a very convenient way of displaying information or digital data in the form of numbers, letters or even alpha-numerical characters Typically, seven-segment displays consist of seven individual coloured LED's (called the segments), within one single display package. In order to produce the required numbers from 0 to 9, respectively, on the display, the correct combination of LED segments need to be illuminated. A standard seven-segment LED display generally has 8 input connections, one for each LED segment (see the following figure: Individual segments are indicated by a b, c, d,e, f, g, respectively) and one that acts as a common terminal or connection for all the internal display segments. So in order to display the number 3 for example, segments a, b, c, d and g would need to be illuminated. If we wanted to display a different number, then a different set of segments would need to be illuminated In this task, you will design a BCD to seven-segment decoder, which takes a 4-bit input representing a number from 0 to 9 and generates an appropriate 7-bit output to illuminate the appropriate elements of the display to represent the digit. The design steps below are to assist you to complete this task:Explanation / Answer
function varargout = LED_blink_arduino(varargin)
% LED_BLINK_ARDUINO MATLAB code for LED_blink_arduino.fig
% LED_BLINK_ARDUINO, by itself, creates a new LED_BLINK_ARDUINO or raises the existing
% singleton*.
%
% H = LED_BLINK_ARDUINO returns the handle to a new LED_BLINK_ARDUINO or the handle to
% the existing singleton*.
%
% LED_BLINK_ARDUINO('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in LED_BLINK_ARDUINO.M with the given input arguments.
%
% LED_BLINK_ARDUINO('Property','Value',...) creates a new LED_BLINK_ARDUINO or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before LED_blink_arduino_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to LED_blink_arduino_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help LED_blink_arduino
% Last Modified by GUIDE v2.5 13-Jul-2014 19:16:07
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @LED_blink_arduino_OpeningFcn, ...
'gui_OutputFcn', @LED_blink_arduino_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before LED_blink_arduino is made visible.
function LED_blink_arduino_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to LED_blink_arduino (see VARARGIN)
% Choose default command line output for LED_blink_arduino
handles.output = hObject;
%choose which webcam (winvideo-1) and which mode (YUY2_176x144)
vid = videoinput('winvideo', 1, 'YUY2_640x480');
% only capture one frame per trigger, we are not recording a video
vid.FramesPerTrigger = 1;
% output would image in RGB color space
vid.ReturnedColorspace = 'rgb';
% tell matlab to start the webcam on user request, not automatically
triggerconfig(vid, 'manual');
% we need this to know the image height and width
vidRes = get(vid, 'VideoResolution');
% image width
imWidth = vidRes(1);
% image height
imHeight = vidRes(2);
% number of bands of our image (should be 3 because it's RGB)
nBands = get(vid, 'NumberOfBands');
% create an empty image container and show it on axPreview
hImage = image(zeros(imHeight, imWidth, nBands), 'parent', handles.axes1);
% begin the webcam preview
preview(vid, hImage);
% Update handles structure
%im=imread('D:ARDUINO_MATLAB_blogpost r12.jpg');
im2=imread('D:ARDUINO_MATLAB_blogpostcommunity logo.jpg');
imshow(im2,'Parent',handles.axes2);
%imshow(im2,'Parent',handles.axes3);
guidata(hObject, handles);
% UIWAIT makes LED_blink_arduino wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = LED_blink_arduino_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in Connect_arduino.
function Connect_arduino_Callback(hObject, eventdata, handles)
% hObject handle to Connect_arduino (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.output = hObject;
global s
handles.s=s;
handles.s=serial('COM3','BAUD', 9600);
fopen(handles.s);
guidata(hObject, handles);
% --- Executes on button press in ON_LED.
function ON_LED_Callback(hObject, eventdata, handles)
% hObject handle to ON_LED (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
fprintf(handles.s,100);
% --- Executes on button press in OFF_LED.
function OFF_LED_Callback(hObject, eventdata, handles)
% hObject handle to OFF_LED (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
fprintf(handles.s,101);
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close all