Question
Following is a simple MATLAB Arduino Uno based app designer program where I press the enter button red blinks first, then motor lifts arms, the
Following is a simple MATLAB Arduino Uno based app designer program where I press the enter button red blinks first, then motor lifts arms, the red light turns off, the green light turns on then, the green light turns off, the red light turns on then the motor puts the arm down. the hardware is working according to the program but the app graphics are not getting updated according to the program
classdef appparknew
% Properties that correspond to app components properties (Access = public) UIFigure matlab.ui.Figure Panel matlab.ui.container.Panel EnterButton matlab.ui.control.Button ExitButton matlab.ui.control.Button goLampLabel matlab.ui.control.Label goLamp matlab.ui.control.Lamp AvailableSpotsLabel matlab.ui.control.Label WELCOMELabel matlab.ui.control.Label stopLampLabel matlab.ui.control.Label stopLamp matlab.ui.control.Lamp end
properties (Access = private) spots= 3; a; Servo; end
% Callbacks that handle component events methods (Access = private)
% Code that executes after component creation function startupFcn(app) app.a= arduino(); app.Servo= servo(app.a,'D7'); app.spots= 3; app.AvailableSpotsLabel.Text = char("Available Spots= " + num2str(app.spots)); end
% Button pushed function: EnterButton function EnterButtonPushed(app, event) pause(1) app.stopLamp.Color ='r'; writeDigitalPin(app.a,'D4',1); if (app.spots>=1) app.stopLamp.Color =[0.89,0.45,0.45]; writeDigitalPin(app.a,'D4',0); app.goLamp.Color ='g'; writeDigitalPin(app.a,'D5',1); writePosition(app.Servo,1) pause(2) app.goLamp.Color=[0.50,0.83,0.50]; writeDigitalPin(app.a,'D5',0); writePosition(app.Servo,0) app.stopLamp.Color ='r'; writeDigitalPin(app.a,'D4',1); app.spots=app.spots-1; app.AvailableSpotsLabel.Text= char("Available Spots= " + num2str(app.spots)); else app.WELCOMELabel.Text = 'booz off'; end end end
% Component initialization methods (Access = private)
% Create UIFigure and components function createComponents(app)
% Create UIFigure and hide until all components are created app.UIFigure = uifigure('Visible', 'off'); app.UIFigure.Position = [100 100 640 480]; app.UIFigure.Name = 'MATLAB App';
% Create Panel app.Panel = uipanel(app.UIFigure); app.Panel.Title = 'Panel'; app.Panel.Position = [14 17 602 445];
% Create EnterButton app.EnterButton = uibutton(app.Panel, 'push'); app.EnterButton.ButtonPushedFcn = createCallbackFcn(app, @EnterButtonPushed, true); app.EnterButton.Position = [11 235 100 22]; app.EnterButton.Text = 'Enter';
% Create ExitButton app.ExitButton = uibutton(app.Panel, 'push'); app.ExitButton.Position = [120 235 100 22]; app.ExitButton.Text = 'Exit';
% Create goLampLabel app.goLampLabel = uilabel(app.Panel); app.goLampLabel.HorizontalAlignment = 'right'; app.goLampLabel.Position = [238 267 25 22]; app.goLampLabel.Text = 'go';
% Create goLamp app.goLamp = uilamp(app.Panel); app.goLamp.Position = [278 267 20 20]; app.goLamp.Color = [0.502 0.8314 0.502];
% Create AvailableSpotsLabel app.AvailableSpotsLabel = uilabel(app.Panel); app.AvailableSpotsLabel.Position = [11 342 174 22]; app.AvailableSpotsLabel.Text = 'Available Spots';
% Create WELCOMELabel app.WELCOMELabel = uilabel(app.Panel); app.WELCOMELabel.Position = [50 393 78 22]; app.WELCOMELabel.Text = 'WELCOME!!!';
% Create stopLampLabel app.stopLampLabel = uilabel(app.Panel); app.stopLampLabel.HorizontalAlignment = 'right'; app.stopLampLabel.Position = [235 308 28 22]; app.stopLampLabel.Text = 'stop';
% Create stopLamp app.stopLamp = uilamp(app.Panel); app.stopLamp.Position = [278 308 20 20]; app.stopLamp.Color = [0.8902 0.451 0.451];
% Show the figure after all components are created app.UIFigure.Visible = 'on'; end end
% App creation and deletion methods (Access = public)
% Construct app function app = appparknew
% Create UIFigure and components createComponents(app)
% Register the app with App Designer registerApp(app, app.UIFigure)
% Execute the startup function runStartupFcn(app, @startupFcn)
if nargout == 0 clear app end end
% Code that executes before app deletion function delete(app)
% Delete UIFigure when app is deleted delete(app.UIFigure) end end end
MATLAB App Panel WELCOME!!! Available Spots stop go Enter Exit MATLAB App Panel WELCOME!!! Available Spots stop go Enter ExitStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started