繁体   English   中英

使用 Arduino mega 2560 与 max 进行 Arduino2max 数字引脚通信

[英]Arduino2max digital pin communication to max using an Arduino mega 2560

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

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

任何帮助和意见将不胜感激!

非常感谢

这是改编自 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);
 }

再次感谢!

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM