Controlling Arduino via Matlab GUI
Show older comments
I'm trying to control a robot via a matlab gui. the problem is I'd like to have arrows pointing left, right, forward, backwards on my gui to control the robot's movements. Two issues:
1. Does matlab have arrow indicators for it's GUI? 2. I only want the respective command ON while I'm holding the arrow key down. When I release the key I want to stop the motion. Is there a way the gui can detect when the arrow is no longer down and issue a command to stop the motor?
Accepted Answer
More Answers (1)
Marty Rothwell
on 29 Dec 2014
0 votes
1 Comment
Sean de Wolski
on 29 Dec 2014
CData is the color data for the button, i.e. the image on it. You could use an image of an arrow for this pretty easily. I don't happen to have any arrow images handy, so here's a push button with my dog point left/right/up/down.
I = imread('zoey.jpg');
I = I(300:end,50:200,:);
I = imresize(I,[100 100]);
% Down
uicontrol('Style','pushbutton','CData',flip(rot90(I)),...
'Units','normalized','Position',[0.4 0.2 0.2 0.2]);
% Right
uicontrol('Style','pushbutton','CData',I,...
'Units','normalized','Position',[0.6 0.4 0.2 0.2]);
% Up
uicontrol('Style','pushbutton','CData',rot90(I),...
'Units','normalized','Position',[0.4 0.6 0.2 0.2]);
% Left
uicontrol('Style','pushbutton','CData',flip(I,2),...
'Units','normalized','Position',[0.2 0.4 0.2 0.2]);

Categories
Find more on Robotics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!