Using Arduino BT for bike odometer

Hi, I am having a problem whilst trying to create an interface between my Arduino and my PC, I have loaded the following code onto my Arduino

int led_pin = 13;
int interrupt_pin_a = 0; // Digital pin #2
int interrupt_pin_b = 1; // Digital pin #3

int signal_pin_a = 2; // Digital pin #2
int signal_pin_b = 3; // Digital pin #3

volatile int state_a = 0;
volatile int state_b = 0;
volatile unsigned long last_seen_millis = 0;
volatile int pause_counter = 0;
volatile int continue_counter = 0;

void setup(){
noInterrupts();
pinMode(led_pin, OUTPUT);
pinMode(signal_pin_a, INPUT );
pinMode(signal_pin_b, INPUT );

digitalWrite(led_pin, LOW);
Serial.begin(9600);

state_a = 0;
state_b = 0;

attachInterrupt(interrupt_pin_a, detect_a, RISING);
attachInterrupt(interrupt_pin_b, detect_b, RISING);
interrupts();

}

void detect_a() {
noInterrupts();

state_a++;

interrupts();
}

void detect_b() {
noInterrupts();

state_b++;

interrupts();
}

void loop(){
if(state_a > 0 && state_b > 0) {
// We saw a falling signal. This indicates
// that the magnet sensor has gone past,
// and we can issue a message over the serial
// port.
noInterrupts();
state_a = 0;
state_b = 0;

// Indicate signal with LED
digitalWrite(led_pin, HIGH);
Serial.println( millis() );
digitalWrite(led_pin, LOW);
interrupts();

last_seen_millis = millis();
// Wait at least 100 milliseconds
// before trying to detect the next interrupt
while( millis() < ( last_seen_millis + 100 ) ) {
state_a = 0;
state_b = 0;
}
}

// We don't see an interrupt from state_a, but
// we should check if we've left the sensor
// in pause mode
while( digitalRead(signal_pin_a) ) {

digitalWrite(led_pin, HIGH);

last_seen_millis = millis();
// Wait at least 100 milliseconds
// before trying to see if we're
// paused
while( millis() < ( last_seen_millis + 100 ) ) {
// Noop
}

// We've waited 100 milliseconds and we're still
// reading positive signal
pause_counter++;

// If we've seen this behavior for 5 seconds,
// pause the exercise.
if(pause_counter > 50) {
Serial.println( "pause" );
last_seen_millis = millis();
while( millis() < ( last_seen_millis + 10000 ) ) {
// Noop
}
}
}
pause_counter = 0;
digitalWrite(led_pin, LOW);

// We don't see an interrupt from state_b, but
// we should check if we've left the sensor
// in continue mode
while( digitalRead(signal_pin_b) ) {

digitalWrite(led_pin, HIGH);

last_seen_millis = millis();
// Wait at least 100 milliseconds
// before trying to see if we're
// paused
while( millis() < ( last_seen_millis + 100 ) ) {
// Noop
}

// We've waited 100 milliseconds and we're still
// reading positive signal
continue_counter++;

// If we've seen this behavior for 5 seconds,
// pause the exercise.
if(continue_counter > 50) {
Serial.println( "continue" );
last_seen_millis = millis();
while( millis() < ( last_seen_millis + 10000 ) ) {
// Noop
}
}
}
continue_counter = 0;

digitalWrite(led_pin, LOW);

}

This is some code from another persons project attempting to achieve a similar result however they are using the Arduino Uno Board. I am a complete beginner to this, have never done microcontroller programming before and have little circuit design experience. The board seems to be sensing the magnet passing by the read switches, however when using the serial monitor that came with the Arduino software nothing seems to be coming up on the screen, I have also downloaded a separate more powerful serial port monitor by Eltima and have had no luck with that.

Please could someone tell advise me how to rectify this I will attach some pictures of my circuit to give some extra insight. Also the green power LED flashes off when I pass the magnet by the reed switches is this correct I really don't know :~ [/https://www.facebook.com/photo.php?fbid=10152939111220646&set=a.10151367977080646.820068.655585645&type=1&theater]
[/https://www.facebook.com/photo.php?fbid=10152939091700646&set=a.10151367977080646.820068.655585645&type=1&theater]
[/https://www.facebook.com/photo.php?fbid=10152939091260646&set=a.10151367977080646.820068.655585645&type=1&theater]
[/https://www.facebook.com/photo.php?fbid=10152939090840646&set=a.10151367977080646.820068.655585645&type=1&theater]

bsimmonds:
Please could someone tell advise me how to rectify this I will attach some pictures of my circuit to give some extra insight.

You missed placing the [ /img ] at the ends of your pic links.

bsimmonds:
Also the green power LED flashes off when I pass the magnet by the reed switches is this correct I really don't know

Not good.
(What's your tummy telling you?)

Sorry I am a noob at forums too, is that really bad if the green pwr led goes out. I've only had the damn thing a week seems to be behaving ok (connecting to computer and connecting to serial monitor) I just cant see anything. The video attached shows what happens as I pass the magnet by the reed switches.

WP_20130623_133328Z.mp4 (2.74 MB)

I haven't seen an "Arduino Bluetooth" like what you have there before.
[It's an official product.] There's no USB so you upload your sketch via BT or ICSP (or both)? That's interesting.

I noticed it has screw terminals for power/+VIN and that you're using a dinky "transistor battery".
I'm going to go out on a limb and suggest that it needs a more substantial source, possibly by making your own battery pack or using a NiMH R/C battery.
(As you used "whilst": Maplin 6AA Battery Box, Order Code: HQ01)

I also found this interesting:
Communication between the BT module and the computer can be temperamental. You might want to open the serial monitor a couple of seconds after resetting the board.
"temperamental"

[I don't have anything for MP4'ing with.]

I bought this unit as BT was built in. Starting to think that I should have gone with the UNO but you would think that there should be an advantage being a dedicated BT board, I will take it into work and try it on a proper power supply perhaps this battery doesn't have enough juice to drive it, However I successfully uploaded code to the board, tried resetting just before opening Serial Monitor before with no luck, as I had to do this when uploading the code. Does the wiring on the breadboard look ok? I'm really not sure. I will try uploading the code again to check whether the AtMega is still working pretty sure it will be though. I use VLC to watch everything its brilliant and very fast

  noInterrupts();
  pinMode(led_pin,    OUTPUT);
  pinMode(signal_pin_a, INPUT );
  pinMode(signal_pin_b, INPUT );

  digitalWrite(led_pin, LOW);
  Serial.begin(9600);

  state_a = 0;
  state_b = 0;

  attachInterrupt(interrupt_pin_a, detect_a, RISING);
  attachInterrupt(interrupt_pin_b, detect_b, RISING);
  interrupts();

Nothing you are doing there requires disabling interrupts. So, don't.

void detect_a() {
  noInterrupts();

  state_a++;

  interrupts();
}

void detect_b() {
  noInterrupts();

  state_b++;

  interrupts();
}

Interrupts are already disabled during an ISR. You should not be diddling with them in the ISRs.

    noInterrupts();
    state_a = 0;
    state_b = 0;

    // Indicate signal with LED
    digitalWrite(led_pin, HIGH);
    Serial.println( millis() );
    digitalWrite(led_pin, LOW);
    interrupts();

Serial.print() requires interrupts. It's useless trying to print with interrupts disabled. You really need to minimize the time that interrupts are disabled.

bsimmonds:
Does the wiring on the breadboard look ok? I'm really not sure.

Can't tell without the schematic of what it is you're supposed to have.
Don't forget to add links to any other devices (datasheets) you're using.
One picture showing everything is best: tidy wiring counts (for clarity), avoid having this or that going under a board or out of the shot, and use good lighting (my camera will take pics w/ inadequate lighting and they look fuzzy for it.)

Something is wrong with my board now I see nothing at all not even lights. going to send back to Arduino for a replacement may buy an UNO as well just to see. I shall go through the Code errors when I get a new one back. Thanks PaulS and Runaway Pancake for your advise, shall be on it again when new one sorted.

going to send back to Arduino for a replacement

Why? If you toasted it, why should the vender replace it?

I didn't toast it, not sure it was working properly in the first place, didn't over power it didn't mess about with the board and code cannot destroy it, well mine could its so crap :frowning: