processing duemilanova firmata & debugging

I’ll pop this and start reading posts elsewhere in this branch of the forum.
I’ve set up a Duemilanova, the AllInputFirmata example-code and Processing example-code “arduino-input”. It compiles without errors but Processing does not respond with expected graphics.
The board tries to catch a click event from a switch that is flipped by dents on a rolling wheel. To get a clear pulse I’ve pulled out the big guns and attached interrupts on both the rising and the falling edge. Goes without saying that the arduino part works. I use the pulse to write a tikPin on or off. Can anyone suggest a reason why it shouldn’t work together with the AllInputFirmata example-code?

// Firmata variables:
#include <Firmata.h>

byte pin;

int analogValue;
int previousAnalogValues[TOTAL_ANALOG_PINS];

byte portStatus[TOTAL_PORTS];	// each bit: 1=pin is digital input, 0=other/ignore
byte previousPINs[TOTAL_PORTS];

/* timer variables */
unsigned long currentMillis;     // store the current value from millis()
unsigned long previousMillis;    // for comparison with currentMillis
/* make sure that the FTDI buffer doesn't go over 60 bytes, otherwise you
   get long, random delays.  So only read analogs every 20ms or so */
int samplingInterval = 19;      // how often to run the main loop (in ms)

void sendPort(byte portNumber, byte portValue)
{
  portValue = portValue & portStatus[portNumber];
  if(previousPINs[portNumber] != portValue) {
    Firmata.sendDigitalPort(portNumber, portValue);
    previousPINs[portNumber] = portValue;
  }
}
//- end Firmata-variables




//int analogInPin = A0 ;
//int val ;
int tikPin = 11 ;
long oldCtr ;
long ctr=0 ;
boolean tikker;
long lastDebounce ;

long oldCtr2 ;
long ctr2=0 ;
boolean tikker2;
long lastDebounce2 ;

boolean stateOn, stateOnOld ;
boolean aTik ;

long beepCtr = 0 ;
long lastdeb3 ;
boolean beeper ;

void setup() {
  Firmata_setup() ;
  //Serial.begin(9600);
  pinMode(tikPin, OUTPUT); 
  attachInterrupt(1, tick, RISING  );
  attachInterrupt(0, tick2, FALLING  );
}// void setup()



void loop() {
  
  void Firmata_loop() ;
 //
  if( oldCtr != ctr ){
    lastDebounce = millis();
    tikker = true ;
  }
   
  if( (lastDebounce - millis()) > 75 ){
    if(tikker &! stateOn){
    tikker=false ;
    turnOn() ;
    oldCtr = ctr ;
    }
  }
  
  
    if( oldCtr2 != ctr2 ){
    lastDebounce2 = millis();
    tikker2 = true ;
  }
  if( (lastDebounce2 - millis()) > 75 ){
    if(tikker2 && stateOn){
    tikker2=false ;
    turnOff() ;
    oldCtr2 = ctr2 ;
    }
  }
  
  
  if( stateOnOld != stateOn ){
    lastdeb3 = millis();
    beeper = true ;
     // Serial.print("tst ") ;
      //Serial.println(beepCtr) ;
   //   delay(5) ;
  }
  
  if( lastdeb3 - millis() > 50 ){
      if(beeper && stateOn){
      // finally
      beepCtr++ ;
      beeper = false ;
//      Serial.print("beep ") ;
//      Serial.println(beepCtr) ;
//      delay(5) ;
      stateOnOld = stateOn ;
      }
  }
  
  
  
//  oldCtr2 = ctr2 ;
//  oldCtr = ctr ;
}// end loop ----------------------------------------------------

void turnOn(){
//  Serial.print("on ") ;
//  Serial.println(ctr) ;
//  delay(10) ; 
digitalWrite(tikPin,HIGH) ;
  stateOn = true ;
}

void tick(){
  ctr++;
//  Serial.println("on") ;
//  delay(2) ;
}// end turnOn --------------------------------------------------

void tick2(){
  ctr2++;
//  Serial.println("off") ;
//  delay(2) ;
  
}// end turnOn --------------------------------------------------

void turnOff(){
//  Serial.println("off ") ; 
//  Serial.println(ctr2) ;
//  delay(10) ; 
digitalWrite(tikPin,LOW) ;
  stateOn =false ;
}// end turnOff -------------------------------------------------

//******************************************* firmata code *******************


void Firmata_setup()
{
  byte i, port, status;

  Firmata.setFirmwareVersion(0, 1);

  for(pin = 0; pin < TOTAL_PINS; pin++) {
    if IS_PIN_DIGITAL(pin) pinMode(PIN_TO_DIGITAL(pin), INPUT);
  }

  for (port=0; port<TOTAL_PORTS; port++) {
    status = 0;
    for (i=0; i<8; i++) {
      if (IS_PIN_DIGITAL(port * 8 + i)) status |= (1 << i);
    }
    portStatus[port] = status;
  }

  Firmata.begin(57600);
}

void Firmata_loop()
{
  byte i;

  for (i=0; i<TOTAL_PORTS; i++) {
      sendPort(i, readPort(i, 0xff));
  }
  /* make sure that the FTDI buffer doesn't go over 60 bytes, otherwise you
     get long, random delays.  So only read analogs every 20ms or so */
  currentMillis = millis();
  if(currentMillis - previousMillis > samplingInterval) {
    previousMillis += samplingInterval;
    while(Firmata.available()) {
      Firmata.processInput();
    }
    for(pin = 0; pin < TOTAL_ANALOG_PINS; pin++) {
      analogValue = analogRead(pin);
      if(analogValue != previousAnalogValues[pin]) {
        Firmata.sendAnalog(pin, analogValue); 
        previousAnalogValues[pin] = analogValue;
      }
    }
  }
}

How do I ‘put’ serial debug-data on the processing screen?
I’ll try to make a minimal setup and listen to only one pin, but with no prior experience and no error or debug info … it will be frustrating.

Goes without saying that the arduino part works.

I don't think it does, really.

I use the pulse to write a tikPin on or off.

I know what analog pins are, and I know what digital pins are. I have no idea what a tikPin is.

Can anyone suggest a reason why it shouldn't work together with the AllInputFirmata example-code?

Perhaps the tikPin is not on long enough.

  void Firmata_loop() ;

Why do you have a function prototype in the loop() function? That is not calling Firmata_loop().

I hope that you are aware that you can not modify the Firmata sketch, and expect Processing to still work correctly with it.

void Firmata_loop() ;

uups .. I'm surprised that the sketch would compile with that. It brought some

other errors up, but the graphic output is the same.

Goes without saying that the arduino part works.

I don't think it does, really.

Ok, I ment the circuit. I can controle how long on/off is .. it ought to have had time enough, but it's certainly a legitimate concern. If it's very slow it's not usable for my intend though.

I hope that you are aware that you can not modify the Firmata sketch, and expect Processing to still work correctly with it.

The Firmata code is not changed, but it does run along side by side other code.

SOLVED .. I had picked the wrong port ;o/ Thanks for looking Paul.