MATLAB: Arduino … a lamp

lalamp

clear all
3 a = arduino()
4 configurePin(a,'D6','DigitalInput');
5 configurePin(a,'D9','DigitalOutput');
6 configurePin(a,'A0','DigitalInput');
7 k1 = 0;
8 LED = 0;
9 while(true)
10 while(k1)
11 k1 = readDigitalPin(a,'D6');
12 end
13 while(k1 == 0)
14 k1 = readDigitalPin(a,'D6');
15 end
16 if readVoltage(a,'A0') > 2
17 LED = ~LED;
18 else
19 LED = LED;
20 end
21 writeDigitalPin(a, 'D9', LED);
22 end
why cant i change line 10 and 13 with
while(k1 || (K1 == 0))
k1 = readDigitalPin(a,'D6');
end

Best Answer

duaa - not quite sure what the error message is but I suspect it has to do with your second condition in
while(k1 || (K1 == 0))
Please note how you are using a capital K instead of a lower case k. The conditions should be
while k1 || (k1 == 0)
Related Question