So I have writen this program and I have a problem whit else function. It gives me error: ‘else’ without a previous ‘if’. I dont know what is wrong ?
#include <LiquidCrystal.h>
int fan = 7; //determine fan pin
int redled=8; //determine red led pin
LiquidCrystal lcd(12, 11, 6, 5, 4, 2); //determine ti which pins is connecte LCD
#define pwm 9 ;
void setup()
{ //determine which pin are input or output
pinMode(fan,OUTPUT);
pinMode(redled, OUTPUT);
lcd.begin(16, 2);
lcd.setCursor(6,1);
lcd.print("HELLO!");
lcd.setCursor(7,2);
lcd.print(":)");
delay (120);
lcd.clear();
Serial.begin(9600);
lcd.setCursor(3,2);
lcd.print("Tadej Ahac 5f");
}
void loop()
{
int sensor=digitalRead(A0); //Read sensor value
if(pulseIn(sensor,LOW,90000)); // If input puls is Low for 90000 microseconds
{
analogWrite(fan, 24.5); // On the outpin sets PWM 24.5
lcd.setCursor(1,1);
lcd.print("FAN 10%"); // On the LCD writes speed of the fan
}
else //if criterion is not met than
{
analogWrite(fan, 0); // turn off fan
lcd.setCursor(1,1);
lcd.print("FAN OFF"); // Write on the LCD that the fan is off
}
if (pulseIn(sensor,LOW, 80000)); // If input puls is Low for 80000 microseconds
analogWrite(fan, 51); // On the outpin sets PWM 51
lcd.setCursor(1,1);
lcd.print("FAN 20%"); // On the LCD writes speed of the fan
else
{
analogWrite(fan, 0);
lcd.setCursor(1,1);
lcd.print("FAN OFF");
}
if (pulseIn(sensor,LOW, 70000));
analogWrite(fan, 76.5);
lcd.setCursor(1,1);
lcd.print("FAN 30%");
else
{
analogWrite(fan, 0);
lcd.setCursor(1,1);
lcd.print("FAN OFF");
}
}
if (pulseIn(sensor,LOW, 80000)); // If input puls is Low for 80000 microseconds
analogWrite(fan, 51); // On the outpin sets PWM 51
lcd.setCursor(1,1);
lcd.print("FAN 20%"); // On the LCD writes speed of the fan
else
{