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?
1条评论
Kaustubha Govind
Kaustubha Govind 2011年7月11日
目前尚不清楚这个问题与MATLAB有何关系。从您的代码中,您似乎只是在写入Arduino端口。

登录发表评论。

接受的答案

Mogen Indran
Mogen Indran 2011年7月11日
是的,它是Arduino的样品编码,但我需要用麦克风代替电位计。因此,第一我想在实时图中测试来自电位计的变量。因此任何人都可以帮助我进行简单的编码
3条评论
沃尔特·罗伯森(Walter Roberson)
Please clarify that question. What do you mean by reading from cputime ?

登录发表评论。

更多答案(1)

Chirag Gupta
Chirag Gupta 2011年7月11日
这code above looks like an arduino sketch. Whats you MATLAB code to interface with it?
Have you looked at Arduino包

社区寻宝

在Matlab Central中找到宝藏,发现社区如何为您提供帮助!

Start Hunting!