LCD.h library issues

I'm sure this is more so just an issue with me being unfamiliar with the software, but it also seems to be an issue with the guide I'm using being outdated with broken links. I built ethanol content sensor converters using a few online guides. The converters work fine with certain code, however, I wanted an easy way to bench test them so I purchased an I2C LCD used in the guides and now I'm having issues getting the screen to work. I get an error:

C:\Users\tye\AppData\Local\Temp.arduinoIDE-unsaved202495-11884-bifiyo.fa586\sketch_oct5a\sketch_oct5a.ino:9:10: fatal error: LCD.h: No such file or directory
#include <LCD.h>
^~~~~~~
compilation terminated.
exit status 1

Compilation error: LCD.h: No such file or directory

This seems to be a common error due to library issues and unfortunately the link to the library that was used for this guide is broken. I've gone through a bunch of different fixes in an attempt to get this working and I think at this point I've overwhelmed myself with information.

/************************************************** *****
This program will sample a 50-150hz signal depending on ethanol
content, and output a 0-5V signal via PWM.
The LCD will display ethanol content, hz input, mv output, fuel temp
************************************************** ******/

// include the library code:
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

#define I2C_ADDR 0x27 // <<- Add your address here.
#define Rs_pin 0
#define Rw_pin 1
#define En_pin 2
#define BACKLIGHT_PIN 3
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7

LiquidCrystal_I2C lcd(0x27,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin ,D7_pin);

int inpPin = 8; //define input pin to 8
int outPin = 11; //define PWM output, possible pins with LCD and 32khz freq. are 3 and 11 (UNO)

//Define global variables
volatile uint16_t revTick; //Ticks per revolution
uint16_t pwm_output = 0; //integer for storing PWM value (0-255 value)
int HZ; //unsigned 16bit integer for storing HZ input
int ethanol = 0; //Store ethanol percentage here
float expectedv; //store expected voltage here - range for typical GM sensors is usually 0.5-4.5v
uint16_t voltage = 0; //Store display millivoltage here (0-5000)
int duty; //Duty cycle (0.0-100.0)
float period; //Store period time here (eg.0.0025 s)
float temperature = 0; //Store fuel temperature here
int fahr = 0;
int cels = 0;
static long highTime = 0;
static long lowTime = 0;
static long tempPulse;

void setupTimer() // setup timer1
{
TCCR1A = 0; // normal mode
TCCR1B = 132; // (10000100) Falling edge trigger, Timer = CPU Clock/256, noise cancellation on
TCCR1C = 0; // normal mode
TIMSK1 = 33; // (00100001) Input capture and overflow interupts enabled
TCNT1 = 0; // start from 0
}

ISR(TIMER1_CAPT_vect) // PULSE DETECTED! (interrupt automatically triggered, not called by main program)
{
revTick = ICR1; // save duration of last revolution
TCNT1 = 0; // restart timer for next revolution
}

ISR(TIMER1_OVF_vect) // counter overflow/timeout
{ revTick = 0; } // Ticks per second = 0


void setup()
{
Serial.begin(9600);
pinMode(inpPin,INPUT);
setPwmFrequency(outPin,1); //Modify frequency on PWM output
setupTimer();
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.setBacklightPin(3,POSITIVE);
lcd.setBacklight(HIGH);
// Initial screen formatting
lcd.setCursor(1, 0);
lcd.print("Ethanol: %");
lcd.setCursor(0, 1);
lcd.print(" Hz F");
}

void loop()
{
getfueltemp(inpPin); //read fuel temp from input duty cycle

if (revTick > 0) // Avoid dividing by zero, sample in the HZ
{HZ = 62200 / revTick;} // 3456000ticks per minute, 57600 per second
else
{HZ = 0;} //needs real sensor test to determine correct tickrate

//calculate ethanol percentage
if (HZ > 50) // Avoid dividing by zero
{ethanol = (HZ-50);}
else
{ethanol = 0;}

if (ethanol > 99) // Avoid overflow in PWM
{ethanol = 99;}

expectedv = ((((HZ-50.0)*0.01)*4)+0.5);
//Screen calculations
pwm_output = 1.11 * (255 * (expectedv/5.0)); //calculate output PWM for NEMU

lcd.setCursor(12, 0);
lcd.print(ethanol);

lcd.setCursor(2, 1);
lcd.print(HZ);

lcd.setCursor(12, 1);
lcd.print(fahr); //Use this for celsius

//PWM output
analogWrite(outPin, pwm_output); //write the PWM value to output pin

delay(1000); //make screen more easily readable by not updating it too often

Serial.println(ethanol);
Serial.println(pwm_output);
Serial.println(expectedv);
Serial.println(HZ);
delay(1000);


}

void getfueltemp(int inpPin) { //read fuel temp

tempPulse = pulseIn(inpPin, LOW, 25000); // Measure the low pulse time (timeout after 25ms if no pulse is detected)
if (tempPulse > 0) { // If we get a pulse then update the temperature measurement
lowTime = tempPulse;
float celsius = ((41.25 * (float(lowTime) / 1000)) - 81.25); // Calculate temp in celsius from lowTime pulse
float fahrenheit = ((celsius * 1.8) + 32); // Convert to fahrenheit
temperature = fahrenheit; // Update temperature with specified unit
}
}

duty = ((100*(highTime/(double (lowTime+highTime))))); //Calculate duty cycle (integer extra decimal)
float T = (float(1.0/float(HZ))); //Calculate total period time
float period = float(100-duty)*T; //Calculate the active period time (100-duty)*T
float temp2 = float(10) * float(period); //Convert ms to whole number
temperature = ((40.25 * temp2)-81.25); //Calculate temperature for display (1ms = -40, 5ms = 80)
int cels = int(temperature);
cels = cels*0.1;
float fahrtemp = ((temperature*1.8)+32);
fahr = fahrtemp*0.1;

}

void setPwmFrequency(int pin, int divisor) { //This code snippet raises the timers linked to the PWM outputs
byte mode; //This way the PWM frequency can be raised or lowered. Prescaler of 1 sets PWM output to 32KHz (pin 3, 11)
if(pin == 5 || pin == 6 || pin == 9 || pin == 10) {
switch(divisor) {
case 1: mode = 0x01; break;
case 8: mode = 0x02; break;
case 64: mode = 0x03; break;
case 256: mode = 0x04; break;
case 1024: mode = 0x05; break;
default: return;
}
if(pin == 5 || pin == 6) {
TCCR0B = TCCR0B & 0b11111000 | mode;
} else {
TCCR1B = TCCR1B & 0b11111000 | mode;
}
} else if(pin == 3 || pin == 11) {
switch(divisor) {
case 1: mode = 0x01; break;
case 8: mode = 0x02; break;
case 32: mode = 0x03; break;
case 64: mode = 0x04; break;
case 128: mode = 0x05; break;
case 256: mode = 0x06; break;
case 1024: mode = 0x7; break;
default: return;
}
TCCR2B = TCCR2B & 0b11111000 | mode;
}
}

This is the code being used, I've downloaded probably 40 different libraries and I'm sure this is just an issue with the way I'm doing something but maybe someone else can walk me through this. I did run a couple of the library examples such as the hello world and those work fine. My address for the LCD is correct at 0x27, what am I missing aside from obviously this code isn't compiling and the LCD.h properly. Thanks for the help!

try so

//YWROBOT
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display

void setup()
{
  lcd.init();                      // initialize the lcd 
  lcd.init();
  // Print a message to the LCD.
  lcd.backlight();
  lcd.setCursor(0,0);
  lcd.print("Hello, world!");
  lcd.setCursor(2,1);
  lcd.print(" Arduino!");  
}

void loop(){}
1 Like

post a picture of the LCD, we need to know if it has the IwC backpack with 4 pins on one end versus a bunch of pins for the NON I2C version.

C:\Users\tye\AppData\Local\Temp.arduinoIDE-unsaved202495-9496-1enr2iw.rf0vk\sketch_oct5a\sketch_oct5a.ino:4:10: fatal error: LiquidCrystal_I2C.h: No such file or directory
#include <LiquidCrystal_I2C.h>
^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1

Compilation error: LiquidCrystal_I2C.h: No such file or directory

I get this error code when compiling. I did wipe my IDE and start over fresh because I had downloaded so many different libraries I wanted to start from scratch again. I don't see a liquidcrystal_l2c.h library in my current libraries now either, I did previously have one prior to wiping it. I dont want to download anything new without being sure I'm downloading the correct ones though

They do have the backpack, this is the amazon link to the LCD's I purchased

Ok, then you need to go into the LibraryManager and install the library, here is what it will look like. You will see an Install button, click it and off you go.

Perfect, thats the one I had initially. Downloaded and your file works perfectly now, went back to flash in my original code and same error as original post

Great, remember to give @kolaha the Solved, he showed you first, I just piled on when it appeared you didn't know how to use his advice.

Their code works, but my original one still doesnt

Ok, but he solved the missing library. Repost both your code, and your verbose compile log both in code tags as a new topic. And mark @kolaha post as the Solved as that is the only error showing in your OP.

My OP shows the error

C:\Users\tye\AppData\Local\Temp.arduinoIDE-unsaved202495-9496-1enr2iw.rf0vk\sketch_oct5a\sketch_oct5a.ino:9:10: fatal error: LCD.h: No such file or directory
#include <LCD.h>
^~~~~~~
compilation terminated.
exit status 1

Compilation error: LCD.h: No such file or directory

Which is the same error I'm currently getting. My OP wasn't about the missing library as I had that library when I posted

BTW, the following is unneeded for I2C


And the following is incorrect for I2C (see library examples for correct coding)

Also, before posting again, please use the menu Tools then Autoformat. Makes you code more readable.

Sorry I'm not super familiar with this site nor coding in general, where exactly is the autoformat at? I see a tool icon for replies but I don't think thats what I'm looking for? I also didn't write this code, this was pulled from a "known" working guide which is why I used it. I've deleted out a few things in an attempt to get it working but didn't want to skew the code out of my realm of knowledge

It's in the IDE. Good luck if this isn't your code.

/************************************************** *****
This program will sample a 50-150hz signal depending on ethanol
content, and output a 0-5V signal via PWM.
The LCD will display ethanol content, hz input, mv output, fuel temp
************************************************** ******/

// include the library code:
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

#define I2C_ADDR 0x27  // <<- Add your address here.
#define Rs_pin 0
#define Rw_pin 1
#define En_pin 2
#define BACKLIGHT_PIN 3
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7

LiquidCrystal_I2C lcd(0x27, En_pin, Rw_pin, Rs_pin, D4_pin, D5_pin, D6_pin, D7_pin);

int inpPin = 8;   //define input pin to 8
int outPin = 11;  //define PWM output, possible pins with LCD and 32khz freq. are 3 and 11 (UNO)

//Define global variables
volatile uint16_t revTick;  //Ticks per revolution
uint16_t pwm_output = 0;    //integer for storing PWM value (0-255 value)
int HZ;                     //unsigned 16bit integer for storing HZ input
int ethanol = 0;            //Store ethanol percentage here
float expectedv;            //store expected voltage here - range for typical GM sensors is usually 0.5-4.5v
uint16_t voltage = 0;       //Store display millivoltage here (0-5000)
int duty;                   //Duty cycle (0.0-100.0)
float period;               //Store period time here (eg.0.0025 s)
float temperature = 0;      //Store fuel temperature here
int fahr = 0;
int cels = 0;
static long highTime = 0;
static long lowTime = 0;
static long tempPulse;

void setupTimer()  // setup timer1
{
  TCCR1A = 0;    // normal mode
  TCCR1B = 132;  // (10000100) Falling edge trigger, Timer = CPU Clock/256, noise cancellation on
  TCCR1C = 0;    // normal mode
  TIMSK1 = 33;   // (00100001) Input capture and overflow interupts enabled
  TCNT1 = 0;     // start from 0
}

ISR(TIMER1_CAPT_vect)  // PULSE DETECTED! (interrupt automatically triggered, not called by main program)
{
  revTick = ICR1;  // save duration of last revolution
  TCNT1 = 0;       // restart timer for next revolution
}

ISR(TIMER1_OVF_vect)  // counter overflow/timeout
{
  revTick = 0;
}  // Ticks per second = 0


void setup() {
  Serial.begin(9600);
  pinMode(inpPin, INPUT);
  setPwmFrequency(outPin, 1);  //Modify frequency on PWM output
  setupTimer();
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  lcd.setBacklightPin(3, POSITIVE);
  lcd.setBacklight(HIGH);
  // Initial screen formatting
  lcd.setCursor(1, 0);
  lcd.print("Ethanol: %");
  lcd.setCursor(0, 1);
  lcd.print(" Hz F");
}

void loop() {
  getfueltemp(inpPin);  //read fuel temp from input duty cycle

  if (revTick > 0)           // Avoid dividing by zero, sample in the HZ
  { HZ = 62200 / revTick; }  // 3456000ticks per minute, 57600 per second
  else {
    HZ = 0;
  }  //needs real sensor test to determine correct tickrate

  //calculate ethanol percentage
  if (HZ > 50)  // Avoid dividing by zero
  {
    ethanol = (HZ - 50);
  } else {
    ethanol = 0;
  }

  if (ethanol > 99)  // Avoid overflow in PWM
  { ethanol = 99; }

  expectedv = ((((HZ - 50.0) * 0.01) * 4) + 0.5);
  //Screen calculations
  pwm_output = 1.11 * (255 * (expectedv / 5.0));  //calculate output PWM for NEMU

  lcd.setCursor(12, 0);
  lcd.print(ethanol);

  lcd.setCursor(2, 1);
  lcd.print(HZ);

  lcd.setCursor(12, 1);
  lcd.print(fahr);  //Use this for celsius

  //PWM output
  analogWrite(outPin, pwm_output);  //write the PWM value to output pin

  delay(1000);  //make screen more easily readable by not updating it too often

  Serial.println(ethanol);
  Serial.println(pwm_output);
  Serial.println(expectedv);
  Serial.println(HZ);
  delay(1000);
}

void getfueltemp(int inpPin) {  //read fuel temp

  tempPulse = pulseIn(inpPin, LOW, 25000);  // Measure the low pulse time (timeout after 25ms if no pulse is detected)
  if (tempPulse > 0) {                      // If we get a pulse then update the temperature measurement
    lowTime = tempPulse;
    float celsius = ((41.25 * (float(lowTime) / 1000)) - 81.25);  // Calculate temp in celsius from lowTime pulse
    float fahrenheit = ((celsius * 1.8) + 32);                    // Convert to fahrenheit
    temperature = fahrenheit;                                     // Update temperature with specified unit
  }
}

duty = ((100 * (highTime / (double(lowTime + highTime)))));  //Calculate duty cycle (integer extra decimal)
float T = (float(1.0 / float(HZ)));                          //Calculate total period time
float period = float(100 - duty) * T;                        //Calculate the active period time (100-duty)*T
float temp2 = float(10) * float(period);                     //Convert ms to whole number
temperature = ((40.25 * temp2) - 81.25);                     //Calculate temperature for display (1ms = -40, 5ms = 80)
int cels = int(temperature);
cels = cels * 0.1;
float fahrtemp = ((temperature * 1.8) + 32);
fahr = fahrtemp * 0.1;
}

void setPwmFrequency(int pin, int divisor) {  //This code snippet raises the timers linked to the PWM outputs
  byte mode;                                  //This way the PWM frequency can be raised or lowered. Prescaler of 1 sets PWM output to 32KHz (pin 3, 11)
  if (pin == 5 || pin == 6 || pin == 9 || pin == 10) {
    switch (divisor) {
      case 1: mode = 0x01; break;
      case 8: mode = 0x02; break;
      case 64: mode = 0x03; break;
      case 256: mode = 0x04; break;
      case 1024: mode = 0x05; break;
      default: return;
    }
    if (pin == 5 || pin == 6) {
      TCCR0B = TCCR0B & 0b11111000 | mode;
    } else {
      TCCR1B = TCCR1B & 0b11111000 | mode;
    }
  } else if (pin == 3 || pin == 11) {
    switch (divisor) {
      case 1: mode = 0x01; break;
      case 8: mode = 0x02; break;
      case 32: mode = 0x03; break;
      case 64: mode = 0x04; break;
      case 128: mode = 0x05; break;
      case 256: mode = 0x06; break;
      case 1024: mode = 0x7; break;
      default: return;
    }
    TCCR2B = TCCR2B & 0b11111000 | mode;
  }
}

Hopefully that worked better but it looks the same on my end

I am ging to do a little fixing for you, give me a couple minutes and I will post back your code

I assume part of this is the fact that I dont have an LCD.h file in my library folder? This code was written years ago and maybe the way the library lookup has changed how this works? When I google this error I see other people with this LCD.h file in their library folder but the posts are also old

STOP. Everything is fixed, except that you have lines 125 to 134 misplaced, I will leave that to you to fix. Here is your code that is fixed for LCD and compiles after commenting out the lines 125 (approx) to 134 (approx)

/************************************************** *****
This program will sample a 50-150hz signal depending on ethanol
content, and output a 0-5V signal via PWM.
The LCD will display ethanol content, hz input, mv output, fuel temp
************************************************** ******/

// include the library code:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

int inpPin = 8;   //define input pin to 8
int outPin = 11;  //define PWM output, possible pins with LCD and 32khz freq. are 3 and 11 (UNO)

//Define global variables
volatile uint16_t revTick;  //Ticks per revolution
uint16_t pwm_output = 0;    //integer for storing PWM value (0-255 value)
int HZ;                     //unsigned 16bit integer for storing HZ input
int ethanol = 0;            //Store ethanol percentage here
float expectedv;            //store expected voltage here - range for typical GM sensors is usually 0.5-4.5v
uint16_t voltage = 0;       //Store display millivoltage here (0-5000)
int duty;                   //Duty cycle (0.0-100.0)
float period;               //Store period time here (eg.0.0025 s)
float temperature = 0;      //Store fuel temperature here
int fahr = 0;
int cels = 0;
static long highTime = 0;
static long lowTime = 0;
static long tempPulse;

void setupTimer()  // setup timer1
{
  TCCR1A = 0;    // normal mode
  TCCR1B = 132;  // (10000100) Falling edge trigger, Timer = CPU Clock/256, noise cancellation on
  TCCR1C = 0;    // normal mode
  TIMSK1 = 33;   // (00100001) Input capture and overflow interupts enabled
  TCNT1 = 0;     // start from 0
}

ISR(TIMER1_CAPT_vect)  // PULSE DETECTED! (interrupt automatically triggered, not called by main program)
{
  revTick = ICR1;  // save duration of last revolution
  TCNT1 = 0;       // restart timer for next revolution
}

ISR(TIMER1_OVF_vect)  // counter overflow/timeout
{
  revTick = 0;
}  // Ticks per second = 0


void setup() {
  Serial.begin(9600);
  pinMode(inpPin, INPUT);
  setPwmFrequency(outPin, 1);  //Modify frequency on PWM output
  setupTimer();
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  //lcd.setBacklightPin(3, POSITIVE);
  lcd.setBacklight(HIGH);
  // Initial screen formatting
  lcd.setCursor(1, 0);
  lcd.print("Ethanol: %");
  lcd.setCursor(0, 1);
  lcd.print(" Hz F");
}

void loop() {
  getfueltemp(inpPin);  //read fuel temp from input duty cycle

  if (revTick > 0)           // Avoid dividing by zero, sample in the HZ
  { HZ = 62200 / revTick; }  // 3456000ticks per minute, 57600 per second
  else {
    HZ = 0;
  }  //needs real sensor test to determine correct tickrate

  //calculate ethanol percentage
  if (HZ > 50)  // Avoid dividing by zero
  {
    ethanol = (HZ - 50);
  } else {
    ethanol = 0;
  }

  if (ethanol > 99)  // Avoid overflow in PWM
  { ethanol = 99; }

  expectedv = ((((HZ - 50.0) * 0.01) * 4) + 0.5);
  //Screen calculations
  pwm_output = 1.11 * (255 * (expectedv / 5.0));  //calculate output PWM for NEMU

  lcd.setCursor(12, 0);
  lcd.print(ethanol);

  lcd.setCursor(2, 1);
  lcd.print(HZ);

  lcd.setCursor(12, 1);
  lcd.print(fahr);  //Use this for celsius

  //PWM output
  analogWrite(outPin, pwm_output);  //write the PWM value to output pin

  delay(1000);  //make screen more easily readable by not updating it too often

  Serial.println(ethanol);
  Serial.println(pwm_output);
  Serial.println(expectedv);
  Serial.println(HZ);
  delay(1000);
}

void getfueltemp(int inpPin) {  //read fuel temp

  tempPulse = pulseIn(inpPin, LOW, 25000);  // Measure the low pulse time (timeout after 25ms if no pulse is detected)
  if (tempPulse > 0) {                      // If we get a pulse then update the temperature measurement
    lowTime = tempPulse;
    float celsius = ((41.25 * (float(lowTime) / 1000)) - 81.25);  // Calculate temp in celsius from lowTime pulse
    float fahrenheit = ((celsius * 1.8) + 32);                    // Convert to fahrenheit
    temperature = fahrenheit;                                     // Update temperature with specified unit
  }
}

duty = ((100 * (highTime / (double(lowTime + highTime)))));  //Calculate duty cycle (integer extra decimal)
float T = (float(1.0 / float(HZ)));                          //Calculate total period time
float period = float(100 - duty) * T;                        //Calculate the active period time (100-duty)*T
float temp2 = float(10) * float(period);                     //Convert ms to whole number
temperature = ((40.25 * temp2) - 81.25);                     //Calculate temperature for display (1ms = -40, 5ms = 80)
int cels = int(temperature);
cels = cels * 0.1;
float fahrtemp = ((temperature * 1.8) + 32);
fahr = fahrtemp * 0.1;
}

void setPwmFrequency(int pin, int divisor) {  //This code snippet raises the timers linked to the PWM outputs
  byte mode;                                  //This way the PWM frequency can be raised or lowered. Prescaler of 1 sets PWM output to 32KHz (pin 3, 11)
  if (pin == 5 || pin == 6 || pin == 9 || pin == 10) {
    switch (divisor) {
      case 1: mode = 0x01; break;
      case 8: mode = 0x02; break;
      case 64: mode = 0x03; break;
      case 256: mode = 0x04; break;
      case 1024: mode = 0x05; break;
      default: return;
    }
    if (pin == 5 || pin == 6) {
      TCCR0B = TCCR0B & 0b11111000 | mode;
    } else {
      TCCR1B = TCCR1B & 0b11111000 | mode;
    }
  } else if (pin == 3 || pin == 11) {
    switch (divisor) {
      case 1: mode = 0x01; break;
      case 8: mode = 0x02; break;
      case 32: mode = 0x03; break;
      case 64: mode = 0x04; break;
      case 128: mode = 0x05; break;
      case 256: mode = 0x06; break;
      case 1024: mode = 0x7; break;
      default: return;
    }
    TCCR2B = TCCR2B & 0b11111000 | mode;
  }
}

I haven't touched 125-134 yet but I did try to verify it and this is the error I get when I do?

C:\Users\tye\AppData\Local\Temp\.arduinoIDE-unsaved202495-9496-1enr2iw.rf0vk\sketch_oct5a\sketch_oct5a.ino: In function 'void setup()':
C:\Users\tye\AppData\Local\Temp\.arduinoIDE-unsaved202495-9496-1enr2iw.rf0vk\sketch_oct5a\sketch_oct5a.ino:56:3: error: 'setPwmFrequency' was not declared in this scope
   setPwmFrequency(outPin, 1);  //Modify frequency on PWM output
   ^~~~~~~~~~~~~~~
C:\Users\tye\AppData\Local\Temp\.arduinoIDE-unsaved202495-9496-1enr2iw.rf0vk\sketch_oct5a\sketch_oct5a.ino: At global scope:
C:\Users\tye\AppData\Local\Temp\.arduinoIDE-unsaved202495-9496-1enr2iw.rf0vk\sketch_oct5a\sketch_oct5a.ino:125:1: error: 'duty' does not name a type
 duty = ((100 * (highTime / (double(lowTime + highTime)))));  //Calculate duty cycle (integer extra decimal)
 ^~~~
C:\Users\tye\AppData\Local\Temp\.arduinoIDE-unsaved202495-9496-1enr2iw.rf0vk\sketch_oct5a\sketch_oct5a.ino:127:7: error: redefinition of 'float period'
 float period = float(100 - duty) * T;                        //Calculate the active period time (100-duty)*T
       ^~~~~~
C:\Users\tye\AppData\Local\Temp\.arduinoIDE-unsaved202495-9496-1enr2iw.rf0vk\sketch_oct5a\sketch_oct5a.ino:24:7: note: 'float period' previously declared here
 float period;               //Store period time here (eg.0.0025 s)
       ^~~~~~
C:\Users\tye\AppData\Local\Temp\.arduinoIDE-unsaved202495-9496-1enr2iw.rf0vk\sketch_oct5a\sketch_oct5a.ino:129:1: error: 'temperature' does not name a type
 temperature = ((40.25 * temp2) - 81.25);                     //Calculate temperature for display (1ms = -40, 5ms = 80)
 ^~~~~~~~~~~
C:\Users\tye\AppData\Local\Temp\.arduinoIDE-unsaved202495-9496-1enr2iw.rf0vk\sketch_oct5a\sketch_oct5a.ino:130:5: error: redefinition of 'int cels'
 int cels = int(temperature);
     ^~~~
C:\Users\tye\AppData\Local\Temp\.arduinoIDE-unsaved202495-9496-1enr2iw.rf0vk\sketch_oct5a\sketch_oct5a.ino:27:5: note: 'int cels' previously defined here
 int cels = 0;
     ^~~~
C:\Users\tye\AppData\Local\Temp\.arduinoIDE-unsaved202495-9496-1enr2iw.rf0vk\sketch_oct5a\sketch_oct5a.ino:131:1: error: 'cels' does not name a type
 cels = cels * 0.1;
 ^~~~
C:\Users\tye\AppData\Local\Temp\.arduinoIDE-unsaved202495-9496-1enr2iw.rf0vk\sketch_oct5a\sketch_oct5a.ino:133:1: error: 'fahr' does not name a type
 fahr = fahrtemp * 0.1;
 ^~~~
C:\Users\tye\AppData\Local\Temp\.arduinoIDE-unsaved202495-9496-1enr2iw.rf0vk\sketch_oct5a\sketch_oct5a.ino:134:1: error: expected declaration before '}' token
 }
 ^

exit status 1

Compilation error: 'setPwmFrequency' was not declared in this scope

My best guess is that lines 125 to 134 belong to the function immediately before. I fixed it and it compiles fine. NO guarantees, but here it is

/************************************************** *****
This program will sample a 50-150hz signal depending on ethanol
content, and output a 0-5V signal via PWM.
The LCD will display ethanol content, hz input, mv output, fuel temp
************************************************** ******/

// include the library code:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

int inpPin = 8;   //define input pin to 8
int outPin = 11;  //define PWM output, possible pins with LCD and 32khz freq. are 3 and 11 (UNO)

//Define global variables
volatile uint16_t revTick;  //Ticks per revolution
uint16_t pwm_output = 0;    //integer for storing PWM value (0-255 value)
int HZ;                     //unsigned 16bit integer for storing HZ input
int ethanol = 0;            //Store ethanol percentage here
float expectedv;            //store expected voltage here - range for typical GM sensors is usually 0.5-4.5v
uint16_t voltage = 0;       //Store display millivoltage here (0-5000)
int duty;                   //Duty cycle (0.0-100.0)
float period;               //Store period time here (eg.0.0025 s)
float temperature = 0;      //Store fuel temperature here
int fahr = 0;
int cels = 0;
static long highTime = 0;
static long lowTime = 0;
static long tempPulse;

void setupTimer()  // setup timer1
{
  TCCR1A = 0;    // normal mode
  TCCR1B = 132;  // (10000100) Falling edge trigger, Timer = CPU Clock/256, noise cancellation on
  TCCR1C = 0;    // normal mode
  TIMSK1 = 33;   // (00100001) Input capture and overflow interupts enabled
  TCNT1 = 0;     // start from 0
}

ISR(TIMER1_CAPT_vect)  // PULSE DETECTED! (interrupt automatically triggered, not called by main program)
{
  revTick = ICR1;  // save duration of last revolution
  TCNT1 = 0;       // restart timer for next revolution
}

ISR(TIMER1_OVF_vect)  // counter overflow/timeout
{
  revTick = 0;
}  // Ticks per second = 0


void setup() {
  Serial.begin(9600);
  pinMode(inpPin, INPUT);
  setPwmFrequency(outPin, 1);  //Modify frequency on PWM output
  setupTimer();
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  //lcd.setBacklightPin(3, POSITIVE);
  lcd.setBacklight(HIGH);
  // Initial screen formatting
  lcd.setCursor(1, 0);
  lcd.print("Ethanol: %");
  lcd.setCursor(0, 1);
  lcd.print(" Hz F");
}

void loop() {
  getfueltemp(inpPin);  //read fuel temp from input duty cycle

  if (revTick > 0)           // Avoid dividing by zero, sample in the HZ
  { HZ = 62200 / revTick; }  // 3456000ticks per minute, 57600 per second
  else {
    HZ = 0;
  }  //needs real sensor test to determine correct tickrate

  //calculate ethanol percentage
  if (HZ > 50)  // Avoid dividing by zero
  {
    ethanol = (HZ - 50);
  } else {
    ethanol = 0;
  }

  if (ethanol > 99)  // Avoid overflow in PWM
  { ethanol = 99; }

  expectedv = ((((HZ - 50.0) * 0.01) * 4) + 0.5);
  //Screen calculations
  pwm_output = 1.11 * (255 * (expectedv / 5.0));  //calculate output PWM for NEMU

  lcd.setCursor(12, 0);
  lcd.print(ethanol);

  lcd.setCursor(2, 1);
  lcd.print(HZ);

  lcd.setCursor(12, 1);
  lcd.print(fahr);  //Use this for celsius

  //PWM output
  analogWrite(outPin, pwm_output);  //write the PWM value to output pin

  delay(1000);  //make screen more easily readable by not updating it too often

  Serial.println(ethanol);
  Serial.println(pwm_output);
  Serial.println(expectedv);
  Serial.println(HZ);
  delay(1000);
}

void getfueltemp(int inpPin) {  //read fuel temp

  tempPulse = pulseIn(inpPin, LOW, 25000);  // Measure the low pulse time (timeout after 25ms if no pulse is detected)
  if (tempPulse > 0) {                      // If we get a pulse then update the temperature measurement
    lowTime = tempPulse;
    float celsius = ((41.25 * (float(lowTime) / 1000)) - 81.25);  // Calculate temp in celsius from lowTime pulse
    float fahrenheit = ((celsius * 1.8) + 32);                    // Convert to fahrenheit
    temperature = fahrenheit;                                     // Update temperature with specified unit
  }
  //}

  duty = ((100 * (highTime / (double(lowTime + highTime)))));  //Calculate duty cycle (integer extra decimal)
  float T = (float(1.0 / float(HZ)));                          //Calculate total period time
  float period = float(100 - duty) * T;                        //Calculate the active period time (100-duty)*T
  float temp2 = float(10) * float(period);                     //Convert ms to whole number
  temperature = ((40.25 * temp2) - 81.25);                     //Calculate temperature for display (1ms = -40, 5ms = 80)
  int cels = int(temperature);
  cels = cels * 0.1;
  float fahrtemp = ((temperature * 1.8) + 32);
  fahr = fahrtemp * 0.1;
}

void setPwmFrequency(int pin, int divisor) {  //This code snippet raises the timers linked to the PWM outputs
  byte mode;                                  //This way the PWM frequency can be raised or lowered. Prescaler of 1 sets PWM output to 32KHz (pin 3, 11)
  if (pin == 5 || pin == 6 || pin == 9 || pin == 10) {
    switch (divisor) {
      case 1: mode = 0x01; break;
      case 8: mode = 0x02; break;
      case 64: mode = 0x03; break;
      case 256: mode = 0x04; break;
      case 1024: mode = 0x05; break;
      default: return;
    }
    if (pin == 5 || pin == 6) {
      TCCR0B = TCCR0B & 0b11111000 | mode;
    } else {
      TCCR1B = TCCR1B & 0b11111000 | mode;
    }
  } else if (pin == 3 || pin == 11) {
    switch (divisor) {
      case 1: mode = 0x01; break;
      case 8: mode = 0x02; break;
      case 32: mode = 0x03; break;
      case 64: mode = 0x04; break;
      case 128: mode = 0x05; break;
      case 256: mode = 0x06; break;
      case 1024: mode = 0x7; break;
      default: return;
    }
    TCCR2B = TCCR2B & 0b11111000 | mode;
  }
}

Good luck, you will need it. This code is a candidate for worse code of the year award.