之前竞培营的时候买过蓝牙,所以家里留了一个(也是为什么想蓝牙通信)。主控串口连接蓝牙再和电脑通信,问题不在串口,而在电脑是如何接收到的数据?什么形式的数据?怎么处理这类数据成为我想要看到的数据甚至生成动态曲线?由于觉得python无所不能,第一时间想到的就是它,结果在下载pybluez模块时出现问题,电脑提示我没有Microsoft Visual C++ 2014的组件工具,这个我百度了也是很多py模块下载时出现的问题
instrhwinfo('Bluetooth'); instrhwinfo('Bluetooth', RemoteName); %Construct a Bluetooth object called b using channel 3 of a Lego Mindstorm robot with RemoteName of NXT.
b = Bluetooth('NXT', 3); %Connect to the remote device.
fopen(b) %Send a message to the remote device using the fwrite function.
fwrite(b, uint8([2,0,1,155])); %Read data from the remote device using the fread function.
name = fread(b,35); %Disconnect the Bluetooth device.
fclose(b); %Clean up by deleting and clearing the object.
You can read and write both text data (ASCII based) and binary data. For text data, use the fscanf and fprintf functions. For binary data, use the fread and fwrite functions. 你可以借助ASCII码或者二进制数据进行读写操作。对于txt数据使用fscanf、fprintf函数,对于二进制数据使用fread、fwrite函数
t = timer('StartDelay',1,'TimerFcn',@t_TimerFcn,'Period',1,'ExecutionMode','fixedRate'); %StartDelay:开始计时后的延时;TimerFcn:定时中断函数;Period:定时时间周期;ExecutionMode:优先级
start(t)
stop(t) Delete(t)
4.3.2 打印变量disp()
1 2
string = sprintf('Have received stRobot_x:%d',stRobot_x(count)); disp(string)