Go Down

Topic: problems with pin 22-53 arduinomega - processing (Read 1 time) previous topic - next topic


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: [Select]

void setup(){
  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 ){       

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

Code: [Select]

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("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?
sorry for mi poor english.


Firmata and the Mega do not play well together. Ditch Firmata and write your own protocol to get data from/to the Arduino.
The art of getting good answers lies in asking good questions.

Go Up