我试图从arduino中读取模拟数据映射到0-100并通过串行通信发送并使用它在delphi7中的vrangularmeter中显示其对应的值但是vrangularmeter没有响应我的数据,我正在使用comport德尔福串行通信 Here is my arduino code snippet
答案 0 :(得分:0)
尝试理解您的代码段并设置解决方案:
procedure ComPortRxChar(Sender: TObject; Count: Integer);
var LReadedStr: String;
begin
// Read string from COM port
ComPort.ReadStr(LReadedStr, Count);
// If string is not empty
if Trim(LReadedStr) <> '' then begin
// Check for status and enable buttons
if Trim(LReadedStr) = 'READY' then begin
btnLedOn.Enabled := True;
btnLedOff.Enabled := True;
end;
// Add string to memo
memResponse.Lines.Add(LReadedStr);
// Move memo vertical scroll bar to end
memResponse.ScrollBy(0, 99999);
end;
end;
示例: https://sourceforge.net/projects/maxbox/files/Arduino/1052_delphi_arduino.txt/download