Simple Sailing Start sequencer Countdown timer

I have a program for a 3 minute countdown timer. It was working great, but I wanted to add in 5 horn blasts to the program, which I did. It worked well, but I noted that when testing it out that it countdown was actually 3 seconds out of sequence and thus inaccurate. I made the appropriate changes to get it back in line.

When I tried to upload the program, the original sparkfun Redboard uno did not show up on the port. I then switched to a new Uno R3 and uploaded the program.

When tested, all I get is a long 10 second duration horn.

here is my program. For the life of me I can't see what stupid alteration I made to make this happen:

Sailing Starter is set to run a 3 minute start sequence for High School sailing. There is a 5 blast warning sequence // before the the start of the 3 minutes. This program is for an Arduino Uno with a 12 volt megamoto motor shield. The shield supplies the 12v to the horn.

int motor = 11; void setup(){ pinMode(motor,OUTPUT); } void loop(){ Minwarn(); wait(10.00); Min3(); wait(56.25); Min2(); wait(27.5); Min1Half(); wait(26.75); Min1(); wait(28.75); Sec30(); wait(7.75); Sec20(); wait(8.5); Sec10(); wait(4.25); Sec5To1(); Sec0(); while(true){ } } int secToMilliSec(int seconds){ //converts Seconds into milliseconds return (seconds * 1000); } void wait(int Time){// wait delay(secToMilliSec(Time)); } void onOff(int on, int off){ analogWrite(motor,255); wait(on); analogWrite(motor,0); wait(off); } void Minwarn(){ onOff(1.5,.25); onOff(1.5,.25); onOff(1.5,.25); onOff(1.5,.25); onOff(1.5,.25); onOff(1.5,.25); } void Min3(){ onOff(1,.25); onOff(1,.25); onOff(1,.25); } void Min2(){ onOff(1,.25); onOff(1,.25); } void Min1Half(){ onOff(1,.25); onOff(.5,.25); onOff(.5,.25); onOff(.5,.25); } void Min1(){ onOff(1,.25); } void Sec30(){ onOff(.5,.25); onOff(.5,.25); onOff(.5,.25); } void Sec20(){ onOff(.5,.25); onOff(.5,.25); } void Sec10(){ onOff(.5,.25); } void Sec5To1(){ onOff(.5,.5); onOff(.5,.5); onOff(.5,.5); onOff(.5,.5); onOff(.5,.5); } void Sec0(){ onOff(1.5,50); }


You are passing float (floating point) parameters into functions which expect int (integer), so the floats are truncated.

eg.: onOff(.5,.25) becomes onOff(0, 0) onOff(1.5,.25) becomes onOff(1, 0)

You should also know than on an Uno an int variable can hold a value between -32,768 to 32,767.