Welcome! Log In Create A New Profile

Advanced

Arduino Processing Gen7 UART Communication

Posted by Rodriguez 
Arduino Processing Gen7 UART Communication
December 22, 2013 06:50AM
Hi out there,

I´ve build me an Gen7 Board with an ATMEGA 644. I flashed the 20MHz Bootloader on the uC and now I want to try some UART communications on my board.

I want to communicate via Processing IDE with my ("Fake") Arduino Board, the Gen7 Board.

In the first step, I´ve loaded the SimpleDigitalFirmata Example to my Arduino board, and I´ve loaded too the "arduino_output" SW-Example of the Arduino Lib to the Processing IDE.

For me now it is possible to switch on/off some LED´s.

I modified the Processing example as shown below:


import processing.serial.*;

import cc.arduino.*;

Arduino arduino;

color off = color(4, 79, 111);
color on = color(84, 145, 158);

int[] values = { Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW,
Arduino.LOW, Arduino.LOW, Arduino.LOW,
Arduino.LOW, Arduino.LOW, Arduino.LOW,
Arduino.LOW, Arduino.LOW, Arduino.LOW,
Arduino.LOW, Arduino.LOW, Arduino.LOW,
Arduino.LOW, Arduino.LOW, Arduino.LOW,
Arduino.LOW, Arduino.LOW, Arduino.LOW,
Arduino.LOW, Arduino.LOW, Arduino.LOW,
Arduino.LOW, Arduino.LOW, Arduino.LOW,
Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW};

void setup() {
size(970, 200);

// Prints out the available serial ports.
println(Arduino.list());

// Modify this line, by changing the "0" to the index of the serial
// port corresponding to your Arduino board (as it appears in the list
// printed by the line above).
arduino = new Arduino(this, "COM5", 57600);

// Alternatively, use the name of the serial port corresponding to your
// Arduino (in double-quotes), as in the following line.
//arduino = new Arduino(this, "/dev/tty.usbmodem621", 57600);

// Set the Arduino digital pins as outputs.
for (int i = 0; i <= 31; i++)
arduino.pinMode(i, Arduino.OUTPUT);
}

void draw() {
background(off);
stroke(on);

for (int i = 0; i <= 31; i++) {
if (values == Arduino.HIGH)
fill(on);
else
fill(off);

rect(920 - i * 30, 30, 20, 20);
}
}

void mousePressed()
{
int pin = (950 - mouseX) / 30;

// Toggle the pin corresponding to the clicked square.
if (values[pin] == Arduino.LOW) {
arduino.digitalWrite(pin, Arduino.HIGH);
values[pin] = Arduino.HIGH;
} else {
arduino.digitalWrite(pin, Arduino.LOW);
values[pin] = Arduino.LOW;
}
}

It means now, that I have in my new Screen 32 Buttons that I can switch on/off.

Now my problem is, that not all of the Pins of my ATMEGA644 will toggle ?!

For Example Pin 1 (from the Arduino description of the ATMEGA644 shown in the appendix) wouldn´t toggle. As well as the Pin24 till 31.

But I can handle very well the other pins.

Now I think, that I have to change something in the Boards.h File of the Firmata-Lib of the Arduino.
Because there is defined which Ports are digital/analog inputs/outputs.

Is there probably a working Boards.h file especially designed for the ATMEGA644?

I want to define all the Pins, at least the Pin24-31 as digital Output.

Can someone help me?

Thank you and best regards
Rodriguz..

You can answer me in german too winking smiley
Attachments:
open | download - Arduino_atmega644_pinout.jpg (51.6 KB)
Re: Arduino Processing Gen7 UART Communication
December 22, 2013 09:01AM
Hi Guys,

I found out the next step to my goal..

If you download to the Gen7 Board the StandardFirmata and modify the samplingInterval from 19 to 99 as described here [firmata.org] and if you start the StandardFirmata.exe you can switch the Analog Pins as digital pins and everything works pretty well.

Know is my only question, how should I program my code, to eliminate the standardfirmata.exe so that everythings works only with the Processing IDE?

It should be possible to modify the code (but which one?! : Boards.h , Firmata.h, SimpleDigital.Firmata or the arduino_output of the Processing IDE) so that all the Pins are defined as Digital Outputs as it is possible to do with the StandardFirmata.exe. Where does the Exe modify the code to say that for example pin24 is an Digital Output and not an Analog Input?!

My goal is to start Processing with 31 Buttons and to toggle all the Pins with High /Low by clicking the Buttons on the processing GUI.

Regards
Rodriguez
Sorry, only registered users may post in this forum.

Click here to login