% MATLAB Code for Serial Communication between ATTiny44A and MATLAB
% Lukasz Surazynski

clear all;
close all;
clc;
delete(instrfindall);

x=serial('COM6','BAUD', 9600);

fopen(x);
go = true;

while go
                 
a= input('Press 1 to turn ON LED || 2 to turn OFF LED || 3 to read sensor || 0 to leave:');
    fprintf(x,a);  
    
    if (a == 3)
        pause(0.5);
        readData = fscanf(x);
        readData
    end
        if (a == 0)
        go=false;
    end
end
delete(instrfindall);