I am trying to send some integers to an LCD. But it is not working. I have tried in Proteus. Please help. I have uploaded MATLAB and Arduino code below.
MATLAB code:
clear all
clc
answer=1; % this is where we'll store the user's answer
arduino=serial('COM1','BaudRate',9600); % create serial communication object on port COM4
fopen(arduino); % initiate arduino communication
while answer
fprintf(arduino,'%s',char(answer)); % send answer variable content to arduino
answer=input('Enter led value 1 or 2 (1=ON, 2=OFF, 0=EXIT PROGRAM): '); % ask user to enter value for variable answer
end
fclose(arduino); % end communication with arduino
Arduino code:
#include <LiquidCrystal.h>
int matlabData;
LiquidCrystal lcd(12,11,5,4,3,2);
void setup() {
lcd.begin(16,2);
Serial.begin(9600);
}
void loop() {
if(Serial.available()>0) {
matlabData=Serial.read();
lcd.print(matlabData);
}
}