$30 usd paid via paypal to whomever helps me fix code..

Hi, I'm new to Arduino and am getting frustrated with the amount of time I'm spending trying to figure out a seemingly simple code... I will paypal you $30 if your code works for me/you solve my issue. That means if I can copy the code you produce and it works without me having to troubleshoot anything you'll get $30.

I've spend way to much time trying to figure out a code for a 40 yard dash timer. Currently I can serial print an attach interrupt (photosensing lens beam broken) from the time the red LED lights up to the time the sensor beam is broken (crossing the 40yard line).

I do not want to use this setup outside where I will be using the timer setup. Instead of the serial print I want to print my results on an LCD display with an I2c module.

I got this initial code from a forum online and it works great for serial printing the results, please help me integrate the lcd display into my setup so I can use it outside.

Right now I'm turning on a blue led for the "ready" phase, red led for the start phase and attach interrupt for the finish phase which I want to capture and print the results on the lcd display.

I can print "hello world" to the lcd in void setup so I know I have a good connection electrically.

Here's the code for serial printing the results..

long int start =0;
long int revs = 0;
volatile int elapsed =0;

void setup()
{
pinMode (3,INPUT);
digitalWrite(3,LOW);
Serial.begin(9600);

attachInterrupt(digitalPinToInterrupt(3),react,RISING);
digitalWrite(3, LOW);

delay(6000);
pinMode(11,OUTPUT);
digitalWrite(11,HIGH);
delay(8000);
digitalWrite(11,LOW);
start = millis();
pinMode(13,OUTPUT);
digitalWrite(13,HIGH);

}

void loop()
{

}

void react()
{

long fin = millis();
revs =(fin - start);
Serial.println(revs);
start = fin;
elapsed = revs;
}

I've read up on LCD I2C code for over 2 weeks (at least 10 hours total) my LCD info:
LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 16, 2);

Thanks in advance.

I can print "hello world" to the lcd in void setup

Please post your code that does that

Interesting approach to get an issue resolved.
May I ask what country You live in?

Your problem may be related to trying to do this in an Interrupt handler, causing an issue with code in the lcd library. My preference is always to do nothing in the handler but set a flag saying the interrupt fired, and then handle the interrupt in the loop() function.

The only thing you should need to print to the LCD is

void loop()
{
    if (elapsed != 0)   
    {
        char buffer[16];
        sprintf(buffer, "Time: %d", elapsed);
        elapsed = 0;
        lcd.setCursor(0,0);
        lcd.print(buffer);  
    }
}

UKhelibob- Didn’t save the code, got it from a forum if I remember right. It was a couple of weekends ago when I first started working with the lcd display.

Railroader- USA

Cedarlakeinstruments-
tried this code with your loop, did not print to lcd though…

#include <Wire.h> // Library for I2C communication
#include <LiquidCrystal_I2C.h> // Library for LCD
long int start =0;
long int revs = 0;
volatile int elapsed =0;

LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 16, 2);

void setup() {

// put your setup code here, to run once:

pinMode (3,INPUT);
digitalWrite(3,LOW);
Serial.begin(9600);

attachInterrupt(digitalPinToInterrupt(3),react,RISING);
digitalWrite(3, LOW);

delay(6000);
pinMode(11,OUTPUT);
digitalWrite(11,HIGH);
delay(8000);
digitalWrite(11,LOW);
start = millis();
pinMode(13,OUTPUT);
digitalWrite(13,HIGH);

}

void loop() {
// put your main code here, to run repeatedly:

}

void react()
{

long fin = millis();
revs =(fin - start);
Serial.println(revs);
start = fin;
elapsed = revs;

@spartan41 US? I would never guessed.

Didn't save the code, got it from a forum if I remember right.

What about the examples that came with the LCD library ?

I assume you would keep your existing code that prints "Hello, world" in setup().
My code does not initialize the LCD library.

$30 is well below my normal minimum charge for anything Arduino related, but if you send me a PM in the next 30 minutes or so before I have to get off the computer, I'll send you tested, working code for that amount.

I'm kinda bored right now :slight_smile: