Hi everyone,I have developed project for help swimmers to train better. It consist of 25 led's in pool bottom(each meter is one led) and they are lit in programmed time. I have developed input via liudr and led output via 74hc595. It works nice, but I can't make arduino to calculate right time for delay between led's. There is a few variables that operator enter via keyboard: number of 50m passes of pool (integer, can be byte), pass time in minutes (it is easy to enter separately minutes then seconds) and seconds. Goal is to calculate time for delay. I think formula be like this: delay= ((minutes*60)+seconds)/(number of pass*49)*1000. why 49 and not 50? because it will be used in 25m long swimming pool and after 25 led is lit then 24...1 led is lit. So one led must be subtracted from every 50m pass. When I enter formula like that in my program (delay is long unsigned integer) I don't have proper calculation. I have tried with float but this also don't work. Can somebody tell me how to calculate that delay ?

It would be much easier to help you if you posted the code, or at least gave some sample inputs and outputs. Otherwise we are just guessing at what the problem is.

One thing is that to preserve accuracy, you need to re-arrange the calculation a little. Also, if you want unsigned long results, you should use unsigned long constants and variables in the calculation as much as possible.

It would be much easier to help you if you posted the code, or at least gave some sample inputs and outputs. Otherwise we are just guessing at what the problem is.

One thing is that to preserve accuracy, you need to re-arrange the calculation a little. Also, if you want unsigned long results, you should use unsigned long constants and variables in the calculation as much as possible.

ser.print('\f'); ser.println("50m :"); //number of passresponse=get_int(); // Get an integer number from phi-panelint pass=response;ser.print('\f');ser.println("Metars:");ser.print(pass*50);ser.print(" m");delay(1000);

ser.print('\f'); ser.println("Enter minutes:"); //minutesresponse=get_int(); // Get an integer number from phi-panelint minutes=response;ser.print('\f');ser.print(minutes);ser.print(" minutes");delay(1000);

furthermore the speed of a swimmer is not constant near the turning points and when it starts. Also the speed tends to slow down as the swimmer gets more acid in his /her legs and arms.==> one delay will not work.

If I was the trainer I would just use a potmeter on an analog input (averaged to get a stable value) and map that value to the speed of the leds. easier to make and easier to adjust during the training ...

furthermore the speed of a swimmer is not constant near the turning points and when it starts. Also the speed tends to slow down as the swimmer gets more acid in his /her legs and arms.==> one delay will not work.

this project is to swimmer learn to keep constant speed all the time. I'm not a trainer, I'm just a one who want to help kids in local swimming club. They ask me to do it and I'm trying to

It would be much easier to help you if you posted the code, or at least gave some sample inputs and outputs. Otherwise we are just guessing at what the problem is.

One thing is that to preserve accuracy, you need to re-arrange the calculation a little. Also, if you want unsigned long results, you should use unsigned long constants and variables in the calculation as much as possible.