簡體   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