【问题标题】:Arduino2max digital pin communication to max using an Arduino mega 2560使用 Arduino mega 2560 与最大的 Arduino2max 数字引脚通信
【发布时间】:2012-04-07 18:07:24
【问题描述】:

我正在努力将 Arduino Mega 2560 连接到 max msp,我已经调整了 Arduino2max arduino 代码和 max 补丁。

我已经调整了 max 补丁,并成功地将 arduino 的所有 16 个模拟输入转换为 max,但无法将 13 号以上的任何数字引脚转换为 max msp。我想知道是否有人对此有任何成功?

任何帮助和 cmets 将不胜感激!

非常感谢

这里是改编自 Arduino2max v.5 的 arduino 代码,可以在这里找到 http://www.arduino.cc/playground/Interfacing/MaxMSP

int x = 0;              
int ledpin = 13;

void setup ()
{
// 115200 is the default Arduino Bluetooth speed
Serial.begin(115200);
///startup blink
digitalWrite(13,HIGH);              
delay(600);
digitalWrite(13,LOW);
pinMode(13,INPUT);
}



void loop()
{ 
// Check serial buffer for characters
if (Serial.available() > 0){  
if (1){     //Serial.read() == 'r') { // If an 'r' is received then read the pins 
// Read and send analog pins 0-15
for (int pin= 0; pin<=15; pin++)
{ 
 x = analogRead(pin);
 sendValue (x);
}

// Read and send digital pins 2-53
for (int pin= 2; pin<=53; pin++)

{         
 x = digitalRead(pin);
 sendValue (x);
}

 // Send a carriage return to mark end of pin data.
    Serial.println(); 
 // add a delay to prevent crashing/overloading of the serial port
delay (5);                        
 }
}
}
// function to send the pin value followed by a "space".
void sendValue (int x){ 
 Serial.print(x);
 Serial.print(32, BYTE);
 }

再次感谢!

【问题讨论】:

  • 该链接上的文章称“Arduino2Max 是一个带有 Arduino 代码的 Max 补丁,允许您在 Max/MSP 中读取 Arduino 的 12 个数字引脚和 6 个模拟引脚。”哪个对应于整个 Arduino,那么您为什么认为它可以处理更多?
  • 您可能必须破解 Arduino2Max 主机 PC 端才能获得更多价值。你有足够的信心去尝试吗?
  • 感谢您的帮助!我正在使用带有 16 个模拟输入和 54 个数字输入的 mega 2560 板。到目前为止,我已经能够接收所有 16 个模拟输入,但最多只能接收 12 个数字输入
  • 取得了一些成功,但仍然没有额外的数字:(。自信是的,知识渊博的没有。黑客 arduino2max pc 端是什么意思?任何其他方法或建议都非常感谢,非常感谢为您的帮助!
  • 我查看了原始代码,以及您在 Arduino 端的代码。 AFAICT,每个传感器或数字引脚作为数字发送,后跟空格 (Serial.print(32, BYTE);),然后在发送所有传感器/数字引脚后回车 (Serial.println();)。因此,PC 端的程序需要能够接收与 Arduino 发送的一样多的不同传感器/输入值。那有意义吗?因此,如果它在 28 (16+12) 时放弃,那么可能有人需要查看主机 PC 程序,找到接收传感器值的代码,并查看如何扩展该值的数量。

标签: c serial-port arduino max max-msp-jitter


【解决方案1】:

我建议您使用 OSC 协议在 Arduino Mega 和 Max 之间进行通信。 我使用图书馆 ardosc。没有关于它的文档,但它并不难使用,它是一个很好的库。

如果你不能使用它,请不要犹豫,问我一些解释

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-05-04
    • 2021-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多