Pages: [1]   Go Down
Author Topic: arduino mega and processing problem  (Read 568 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 1
Posts: 142
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I am having a strange problem and banging my head into the wall.

I have some code on arduino (a Mega) that works fine but when I transfer that code to processing/Firmata using the arduino library it doesn't seem to work. I just want to push a button and have things happen on the computer.

So with the arduino code I have:
if (digitalRead(53)==HIGH) {
    Serial.println("53!");
    digitalWrite(13, HIGH);
    delay(50);
  }

And with processing I have:

import processing.serial.*;
import cc.arduino.*;

Arduino arduino;

void setup() {
  size(470, 280);
  arduino = new Arduino(this, Arduino.list()[1], 57600);
  arduino.pinMode(53, Arduino.INPUT);
}

void draw() {
  background(0);
  fill(255);

  if (arduino.digitalRead(53) == Arduino.HIGH) {
    ellipse(280, 280, 280, 280);
  }
}

But yet I cannot get that ellipse to draw. Oddly, if I change the HIGH to a LOW in the code and run the program, the ellipse is there. So it seems to notice the button maybe....there must be some small thing I'm missing here! I tried changing the caps on Arduino and arduino but that didn't work, I have simplified the code so it's exactly the same as the Arduino code! When I run the arduino library test programs in Processing everything works fine so I know I have everything hooked up correctly....

 What am I doing wrong???

**edit: the OUTPUT test program works in the arduino library for processing but the INPUT program does not. Does the library not work with an arduino Mega?

***edit2: downloaded the mega library from here: http://www.arduino.cc/playground/interfacing/processing
but in the library folder...nothing was there!!! So I got this one: http://nilseuropa.com/?p=139 but it still isn't working!
« Last Edit: August 24, 2012, 12:09:57 pm by treebykooba » Logged

0
Offline Offline
Full Member
***
Karma: 1
Posts: 142
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

problem solved by uploading SimpleDigitalFirmata to arduino rather than StandardFirmata
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 644
Posts: 50462
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
So with the arduino code I have:
if (digitalRead(53)==HIGH) {
    Serial.println("53!");
    digitalWrite(13, HIGH);
    delay(50);
  }
Quote
problem solved by uploading SimpleDigitalFirmata to arduino rather than StandardFirmata
The first statement shows code that is NOT part of StandardFirmata. This implies that you diddled with the Standard Firmata sketch, and yet still expected it to perform correctly. Not a chance.
Logged

Pages: [1]   Go Up
Jump to: