m0_71039500
2022-05-22 01:37
采纳率: 33.3%
浏览 30

用matlab运行PCF8591的AD转换实验

可以帮忙解释一下下面这些代码分别表示什么函数和什么意思嘛?

%% 采集数据并绘图
% data = zeros(1, 1000);
data = [];
num = 1;
led_state = 1;
%% 采集数据并绘图,根据采集值改变PWM占空比
pic = plot(nan);
xlim([0 1000]);
ylim([0 3.3]);
xlabel('Points');
ylabel('Voltage');
grid on;

while 1   
      if(num <= 1000)      
      data(num) = readRegister(PCF8591, hex2dec('40'));
%         writePWMDutyCycle(mypi, 16, data(num) / 255);       
       num = num + 1;              
       set(pic, 'YData', data*3.3/255, 'Marker', 'o');       
       drawnow;    
else        
        num = 1;       
        data = [];       
        writeLED(mypi, 'led0', led_state);                
         set(pic, 'YData', data*3.3/255, 'Marker', 'o');        
         drawnow;   
 end        
         led_state = ~led_state;
 end

1条回答 默认 最新

相关推荐 更多相似问题