could i get some help the cone will run but i have some kind of problem in case 1 my time all ways shows as 0 0r dosnt thake a reading amd them my et time shows but its just a random number and just keeps adding up as the code runs my over all time and all lights work fine
// Dual stop watch with state machine
// output on serial monitor
// blinking led while running
#include <LiquidCrystal.h>
#include <IRremote.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
const byte startPin = 26;
const byte stopRightPin = 11;
const byte stopLeftPin = 10;
const byte ledPin = 13;
int irstartPin = 23;
const int RECV_PIN = 22;
const byte prestagelPin = 8;
int prestageledlPin = 48;
const byte prestagerPin = 9;
int prestageledrPin = 46;
int stagestartPin = 24;
int stagelPin = 49;
int stagerPin = 45;
int greenlPin = 52;
int greenrPin = 43;
int redlPin = 53;
int redrPin = 42;
int startinPin = 27;
IRrecv irrecv(RECV_PIN);
decode_results results;
boolean stageLeft = HIGH;
boolean stageRight = HIGH;
boolean timerStartState = HIGH;
boolean timerStopLeftState = HIGH;
boolean timerStopRightState = HIGH;
boolean leftFinish = false;
boolean rightFinish = false;
boolean leftJumpStart = false;
boolean rightJumpStart = false;
boolean leftReactionTimer = false;
boolean rightReactionTimer = false;
byte state = 0; // state machine states: 0 ... 3
unsigned long startTime;
unsigned long stopLeft;
unsigned long stopRight;
unsigned long stopLeftReaction;
unsigned long stopRightReaction;
unsigned long RightReactionTime;
unsigned long LeftReactionTime;
unsigned long LeftET;
unsigned long RightET;
unsigned long raceTimeLeft;
unsigned long raceTimeRight;
void setup()
{
lcd.begin(16, 2);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Left");
lcd.setCursor(11, 0);
lcd.print("Right");
pinMode(prestageledlPin, OUTPUT);
pinMode(prestageledrPin, OUTPUT);
pinMode(stagelPin, OUTPUT);
pinMode(stagerPin, OUTPUT);
pinMode(greenlPin, OUTPUT);
pinMode(greenrPin, OUTPUT);
pinMode(redlPin, OUTPUT);
pinMode(redrPin, OUTPUT);
pinMode(prestagelPin, INPUT_PULLUP); //left stage sensor
pinMode(prestagerPin, INPUT_PULLUP); //right stage sensor
pinMode(stagestartPin, INPUT_PULLUP); //input singal from ir to start stage lights/tree
pinMode(startPin, INPUT); //timer start signal input
pinMode(startinPin, OUTPUT); //timer start signal output
pinMode(stopLeftPin, INPUT_PULLUP); //left finish sensor
pinMode(stopRightPin, INPUT_PULLUP); //right finish sensor
pinMode(ledPin, OUTPUT); //timer running led blinks
pinMode(irstartPin, OUTPUT); //ir output signal
Serial.begin (9600);
Serial.println("press start");
irrecv.enableIRIn();
}
sketch_sep25b.ino (8.5 KB)