Pages: [1]   Go Down
Author Topic: problems with pin 22-53 arduinomega - processing  (Read 623 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, i have a problem with digitalread() using arduinoMega. in pin 22-37 and pins 38-53 are outputs.
MY problem is digitalread() in pins 22-37 should return 1,  but it always returns 0 working with processing. This problem working with the software of  arduino, its not happen...
here my code in arduino:
Code:
void setup(){
  Serial.begin(9600);     
  for(int i = 22; i<=37 ;i++){
    pinMode( i , INPUT);
  }
  for(int i = 38; i<=53 ;i++){
    pinMode( i , OUTPUT);
  }
}
void loop(){ 
  for(int i = 22; i<=37 ;i++){   
      if(digitalRead(i) == HIGH ){       
        Serial.println(i);       
      }     
    }
}

this example work fine but in processing not found the digitalread():

Code:
import cc.arduino.*;
import processing.serial.*;
Arduino arduino;

void setup() {
  // size(600,600);
  arduino = new Arduino(this, "COM4", 57600); 
  arduino.pinMode(2, Arduino.INPUT);
  for (int i = 22; i<=37 ;i++) {
    arduino.pinMode(i, Arduino.INPUT);
  }
  for (int i = 38; i<=53 ;i++) {
    arduino.pinMode( i, Arduino.OUTPUT);
  }
}
void draw() {
  for (int i = 22; i<=37 ; i++) {   
    if (arduino.digitalRead(i) == Arduino.HIGH) {       
      println("work");     
    }
    //println("pin: "+i+"  "+arduino.digitalRead(i));
  }
}

the port its fine too...
it works fine if i use one of the pwm pins as input but i dont want to waste them.
so is there a way to get a HIGH with digitalread() on pins 22-37?
thanks!
sorry for mi poor english.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 610
Posts: 49080
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Firmata and the Mega do not play well together. Ditch Firmata and write your own protocol to get data from/to the Arduino.
Logged

Pages: [1]   Go Up
Jump to: