Arduino进行MATLAB实时绘图
11次观看(最近30天)
显示较旧的评论
嗨,我是一名工程专业的学生,也是MATLAB的新手。实际上,我有问题可以实时绘制Arduino的数据。用于测试目的,我使用Arduino AnalogSerialInOut编码。
/*
类似物输入,模拟输出,系列输出
Readsan analog input pin,地图the result to a range from 0 to 255
and使用结果设置输出引脚的脉冲宽调制(PWM)。
Also将结果打印到串行显示器。
这circuit:
*连接电位计到模拟引脚0。
中心电位计的销去模拟引脚。
side电位计的引脚转到 +5V和地面
* LED connectedfrom digital pin 9 to ground
created29 Dec. 2008
Modified2010年9月4日
经过汤姆·伊戈
这个example code is in the public domain.
*/
//这些常数不会改变。他们用来给名字
//到pins used:
constint Analoginpin = A0;// 模拟输入标准计连接到
constint analogOutPin = 9;// Analog outputpin that the LED is attached to
intsensorValue = 0;// value read从锅里
intoutputValue = 0;//值输出到PWM(模拟)
voidsetup() {
//初始化串行9600 bps的通讯:
Serial.Begin(9600);
}
voidloop() {
// 阅读analog in value:
sensorValue = Analogread(ailyoginpin);
// map it到模拟的范围:
outputValue = map(SensorValue,0,1023,0,255);
// change the模拟价值:
analogWrite(analogOutPin, outputValue);
// print the结果到串行显示:
Serial.print("sensor = ");
serial.print(SensorValue);
Serial.print("\t output = ");
serial.println(outputValue);
// wait 10 millisecondsbefore the next loop
//为了模数转换器定居
// 之后上次阅读:
延迟(10);
}
Anyone please can help me?
接受的答案
Mogen Indran
2011年7月11日
3条评论
沃尔特·罗伯森(Walter Roberson)
2011年7月23日
Please clarify that question. What do you mean by reading from cputime ?
更多答案(1)
Chirag Gupta
2011年7月11日
这code above looks like an arduino sketch. Whats you MATLAB code to interface with it?