marsv024 / railuino

Automatically exported from code.google.com/p/railuino
0 stars 0 forks source link

TrackControllerInfrared trouble #7

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I'm trying to get the TrackControllerInfrared to work but with no luck.
When I try the following sketch:

#include <Railuino.h>

const word    LOCO  = 1;
const word    TIME  = 2000;

TrackControllerInfrared ctrlir;

void setup() {
  Serial.begin(115200);
  while (!Serial);  
  Serial.println("Power on");
  ctrlir.setPower(true);
  }

void loop() {  
  Serial.println("Lights on");
  ctrlir.toggleLocoFunction(LOCO, 0);  
  delay(TIME);
}

I would expect to see "Power on" in my serial terminal. The program doesn't 
seem to get that far. It compiles, uploads and starts, but seem to hang at the 
line:
TrackControllerInfrared ctrlir;

There is however Ir activity for a short while as that lines is called (The Ir 
led seem to be working on pin 3, not as the header says on pin 9)

Can you point me in the right direction to get this working?

Original issue reported on code.google.com by elektro...@gmail.com on 3 Feb 2015 at 7:24

GoogleCodeExporter commented 8 years ago
I succeeded in getting the TrackControllerInfrared to work.
I commented out (deleted) some code in the Railuino.cpp file.

The original code contains:

TrackControllerInfrared::TrackControllerInfrared() {
    mPower = true;

    for (int i = 0; i < 2; i++) {
        for (int j = 1; j <= 4; j++) {
            toggleLocoDirection(j);
        }
    }

    setPower(false);
}

When I change this to:

TrackControllerInfrared::TrackControllerInfrared() {
//  mPower = true;
//  
//  for (int i = 0; i < 2; i++) {
//      for (int j = 1; j <= 4; j++) {
//          toggleLocoDirection(j);
//      }
//  }
//  
//  setPower(false);
}

Things work like a charm.
I'm not shure why the loop is there. It only seems to toggle locodirection 
twice, so setting the state of all four locs in the same state as they were in 
the first place.

Original comment by elektro...@gmail.com on 1 Mar 2015 at 3:26

GoogleCodeExporter commented 8 years ago
Hi, 

Having the same issue here with IR, but removing the code as stated in your 
post doesn't changed a thing. Do I have to reimport the library or something 
like that?

Original comment by soullie....@gmail.com on 2 Jun 2015 at 7:56

GoogleCodeExporter commented 8 years ago
As far as I know, you don't have to re-import the library. I just edited the 
Railuino.cpp file with notepad and saved it. Just make sure that the edited 
file is in your "/documents/Arduino/libraries/Railuino/" directory.

Original comment by elektro...@gmail.com on 17 Jun 2015 at 5:04