Question
I am having trouble setting up a while loop in Matlab that will interact with LED's on an arduino board that has already had a
I am having trouble setting up a while loop in Matlab that will interact with LED's on an arduino board that has already had a program uploaded to it. I keep receiving error messages in command:
>> Modified_Fortune Press 1, 2, 3, or 4: 1 Press 1, 2, 3, or 4: 2 Error using serial/fwrite (line 199) Unsuccessful write: OBJ must be connected to the hardware with FOPEN.
Error in Modified_Fortune (line 13) fwrite(s,'1'); %activates pin 12 on arduino board
HERE'S MY CODE WITH SCREENSHOTS AT THE END:
delete(instrfind({'Port'},{'COM3'})) clear all; s=serial('COM3'); fopen(s);
while 1 a=input('Press 1, 2, 3, or 4: ', 's'); fwrite(s,'1'); %activates pin 12 on arduino board fwrite(s,'2');%activates pin 13 on arduino board fwrite(s,'3');%activates pin 15 on arduino board fwrite(s,'4');%activates the channel 12,13,15 on arduino board. fclose(s); end
And the following pictures are my Arduino code:
cUsersyemiz,oneDrive Documents MAILABYHomewonk4 3 Modiried Fortune m 0 EDITOR PUELISH VEW Find FIRs Compara ? Print Adanca Run and Fnd " htps:/www.nathworks.com/matlabcentral/answers 307996-ardaino-st Press a number between 1-5 and receive a fortune! Reter to Arduino coda Moditied Fortune STone modifiod out sport packages not working icate-with-the-cemputer-during-a-while-loop 7Clear a11: 6-S-serial('COM3' while i a-input('ress 1, 2, 3, or 4: twrite(s, ': Sactivates pin 12 on arduino board fwrit:(5'activates pin 13 on arduino board Ewrite(s, 3kactivates pin 15 on arduino board [write(s,'?' } ; &activates the chdnnel 12, 13, 15 on drduino board. close (s) 13- 16 17 16and 15 O Type here to search 1258 AM 44/2018 cUsersyemiz,oneDrive Documents MAILABYHomewonk4 3 Modiried Fortune m 0 EDITOR PUELISH VEW Find FIRs Compara ? Print Adanca Run and Fnd " htps:/www.nathworks.com/matlabcentral/answers 307996-ardaino-st Press a number between 1-5 and receive a fortune! Reter to Arduino coda Moditied Fortune STone modifiod out sport packages not working icate-with-the-cemputer-during-a-while-loop 7Clear a11: 6-S-serial('COM3' while i a-input('ress 1, 2, 3, or 4: twrite(s, ': Sactivates pin 12 on arduino board fwrit:(5'activates pin 13 on arduino board Ewrite(s, 3kactivates pin 15 on arduino board [write(s,'?' } ; &activates the chdnnel 12, 13, 15 on drduino board. close (s) 13- 16 17 16and 15 O Type here to search 1258 AM 44/2018Step 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