Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation error on digitalWrite #8

Open
aristides opened this issue Jun 28, 2013 · 0 comments
Open

Validation error on digitalWrite #8

aristides opened this issue Jun 28, 2013 · 0 comments

Comments

@aristides
Copy link

First of all I would like to congratulate for this product, the code is very well written and organized.

I found you library when trying to find a to communicate with my Arduino Mega 2560 and my Java Code.

When I try to use the digitalWrite I get a validation error saying that the port should between 0 - 7. I checked the source and there's a validations in BoardMessageFactory.validatePort (which is called by the digitalWrite). The code is:
int ports = (int)Math.ceil((maxPin + 1) / 8.0);

In the case of a 2560 board, the maxPin is 54, so the result of the above expression is 7. That's why I didn't accept my digitalWrite on port 13.

Is this validation correct or I'm doing something wrong?

Bellow is my test code that tries to blink the onboard led on the arduino mega:

       MessageFactory board = new Mega2560();
       board.pinMode(13, SetPinModeMessage.PIN_MODE.INPUT.getMode());
       ISerial serial = new IndepProcessingSerialAdapter(new IndepProcessingSerial("/dev/tty.usbmodem1411", 57600));

       Firmata firm = new Firmata(serial);
       serial.start();

       firm.send(board.pinMode(13, SetPinModeMessage.PIN_MODE.OUTPUT.getMode()));

       for (int i = 0; i < 5; i++){
           System.out.println("Setting HIGH");
           firm.send(board.digitalWrite(13, HIGH));
           Thread.sleep(5000);
           System.out.println("Setting LOW");
           firm.send(board.digitalWrite(13, LOW));
           Thread.sleep(1000);
       }

       serial.stop();

Thanks in advance,
Aristides

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant