我正在努力将 Arduino Mega 2560 连接到最大 msp,我已经调整了 Arduino2max arduino 代码和最大补丁。
我已经调整了 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);
}
再次感谢!