Code help required

If possible, could someone help with the code (listed below) please? I cant get it to compile. Any help would be very much appreciated.

Kind regards,

}// Code for Arduino Tachometer using IR Sensor

#include <LiquidCrystal.h>
LiquidCrystal lcd(3, 2, 4, 5, 6, 7);

#define sensor 18
#define start 10

int delay1()
//unsigned int long k;
int i, j;
unsigned int count = 0;
for (i = 0; i < 1000; i++)
for (j = 0; j < 1227; j++)
if (digitalRead(sensor))
while (digitalRead(sensor));
return count;

void setup()
pinMode(sensor, INPUT);
pinMode(start, INPUT);
pinMode(13, OUTPUT);
lcd.begin(16, 2);
lcd.setCursor(0, 1);
lcd.print("Circuit Digest");
digitalWrite(start, HIGH);

void loop( )
unsigned int time = 0, RPM = 0;
lcd.print(" Please Press ");
lcd.setCursor(0, 1);
lcd.print("Button to Start ");
while (digitalRead(start));
lcd.print("Reading RPM.....");
time = delay1();
lcd.print("Please Wait.....");
RPM = (time * 12) / 3;

You have a closing brace on the first line.

@regiment1275, can you please spend some time reading How to get the best out of this forum.

Next edit your post and add code tags to the code that you posted.

Hi Wildbill,

Thank you for your help. I also noticed that it shows void loop errors as well. Im using an Arduino Uno R3. I also need to monitor vibration levels from a SW2480 sensor and also display this. Can you help with this please?

What errors are you getting?

Hi Wildbill,

sketch_jun04c:6:1: error: expected declaration before '}' token
}// Code for Arduino Tachometer using IR Sensor
exit status 1
expected declaration before '}' token

See reply #2...

Hi @regiment1275
See reply #2... and
Last line = };
unnecessary this " ; "

RV mineirin

You force the user to wait for nothing. You do calculations that are completed in milliseconds, then print "please wait" and do nothing at all for 2 seconds. Is that to make it seem like it's a difficult calculation?

1 Like

The code was sent to me to use by a colleague

Doesn't that stand a very good chance of overflowing?

This colleague?

Sure would be easier to follow if you had just told us about this.

I was sent the raw code by my colleague . No link was included to the original source

How's that working out?

It ‘s working now. I followed the advice given by yourself and others. Many thanks for all of your help.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.