-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrototype_Visualizer.m
60 lines (50 loc) · 1.35 KB
/
Prototype_Visualizer.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
clear a
clc
close all
clear vars
format default
%SETUP
%====================================
a = arduino('COM3', 'Uno'); % Change port number to the one used
Mux1 = {'D10', 'D9', 'D8'};
for i=1:3
configurePin(a, Mux1{i}, 'DigitalOutput');
writeDigitalPin(a, Mux1{i}, 0);
end
Mux2 = {'D13', 'D12', 'D11'};
for i=1:3
configurePin(a, Mux2{i}, 'DigitalOutput');
writeDigitalPin(a, Mux2{i}, 1);
end
zOutput = 'D5';
configurePin(a, zOutput, 'PWM');
writePWMDutyCycle(a, zOutput, 1);
zInput = 'A0';
configurePin(a, zInput, 'AnalogInput');
matrix = zeros(8,8);
% LOOP
%====================================
while (true)
for row=0:7
for i=0:2
if bitand(row, bitshift(1,i))
writeDigitalPin(a, Mux1{i+1}, 1);
else
writeDigitalPin(a, Mux1{i+1}, 0);
end
end
for column=0:7
for j=0:2
if bitand(column,bitshift(1,j))
writeDigitalPin(a, Mux2{j+1}, 1);
else
writeDigitalPin(a, Mux2{j+1}, 0);
end
end
inputValue = readVoltage(a, 'A0');
matrix(8-row,8-column) = inputValue;
h = heatmap(matrix, 'ColorLimits',[0 5], 'CellLabelColor','none', 'Title', 'Prototype Force Mat');
drawnow
end
end
end