motor speed and heater control

please,
i need help to fix the error compiling this code ;

#include <LiquidCrystal.h>
LiquidCrystal lcd(12,10,5,4,3,2);
#define PIN_SET 8
#define PIN_DEC 1
#define PIN_INC 0
int buttonState = 0;          // current state of the button
int lastButtonState  = 0;     // previous state of the button

#define motorpin  11
#define heaterpin  9

int startbutton=6;
int stopbutton=7;
unsigned long Temp = 0;
unsigned long Speed = 0;
int Sensorpin = A0;
unsigned long  tempsensor=0 ;
 


void setup() {
 
  pinMode(motorpin, OUTPUT);
  pinMode(heaterpin,OUTPUT);
  pinMode(startbutton,INPUT_PULLUP);
  pinMode(stopbutton,INPUT_PULLUP); 
  pinMode(PIN_INC, INPUT_PULLUP);
  pinMode(PIN_DEC, INPUT_PULLUP);
  pinMode(PIN_SET, INPUT_PULLUP);
  lcd.begin(16,2 );
  lcd.setCursor(0,0);
  lcd.print(" Kemetch Sealer ");
  delay(3000);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Speed:");
  lcd.setCursor(10,0);
  lcd.print("%");
  lcd.setCursor(0,1);
  lcd.print("TEMP:");
  lcd.setCursor(9,1);
  lcd.print("C");
 
  }

 void loop() {
 
  buttonState = digitalRead(PIN_SET);   // read digital pin 2
  if (buttonState != lastButtonState){
     
//*****************************************************************//
   if(buttonState=HIGH){
   
   if(PIN_INC==HIGH && PIN_DEC==LOW){
   
   if(Speed < 10){
     Speed ++;
     delay(100);
     lcd.setCursor(7,0);
     lcd.print(Speed);
   }
   
   if(PIN_INC==LOW && PIN_DEC==HIGH){

    if(Speed >= 0){
    
    Speed --;
    lcd.setCursor(7,0);
     lcd.print(Speed);
    
    delay(100);    }}}
                 }
  
   
   
   
//*****************************************************************//    
     if(buttonState=LOW){

     if(PIN_INC==HIGH && PIN_DEC==LOW){
     if(Temp < 400){
     Temp ++;
     delay(100);
     lcd.setCursor(6,1);
     lcd.print(Temp);
   }
   
   
   if(PIN_INC==LOW && PIN_DEC==HIGH){

    if(Temp >= 0){
    
    Temp --;
    
    delay(100);
    lcd.setCursor(6,1);
    lcd.print(Temp);   
  }
   
   }}
 

 }}}
   
       
  tempsensor=analogRead(A0)
  unsigned long tempvalue = tempsensor*0.48828125;
  
  if(Temp>tempvalue){
 
  if((digitalRead(startbutton)==HIGH)&&(digitalRead( stopbutton)==LOW))
 {
  
   analogWrite(motorpin,(Speed*25.5));
   digitalWrite(heaterpin,HIGH);
  }
  
  
  
 if((digitalRead(startbutton)==LOW)&&(digitalRead( stopbutton)==HIGH))
  {
    
    analogWrite(motorpin,LOW);
    digitalWrite(heaterpin,LOW);
     
 }
 }
 }

If you post the error message it would be easier to help you.

Run the auto format function on your code (ctrl t or Tools, Auto Format) and the cause of the error might show up. Even if it does not, auto format make the code much easier to read.

 }}}   
       
  tempsensor=analogRead(A0)

There is an extra } that closes the loop() function early and the semicolon is missing from the end of the

tempsensor=analogRead(A0)

line. Fix those things and the code compile with a bunch of warnings from the LiquidCrystal library. A better library for the LCDs is the hd44780 library. The hd44780 library is available for install using the IDE library manager.

Your formatting leaves a lot to be desired. Auto format will help as well as removing some of the unnecessary white space.

if(buttonState=HIGH){ ← maybe–> if(buttonState==HIGH){

-jim lee

thnxx so much groundFungus for ur quick reply, i know i’m writing the code with somekind of a difficult coding but thats cuz i’m still a beginner to arduino IDE ,even for proggraming at all.

thats the code after formatting with the errors after.

///////////////////////////////////////////////////////////////////////////////////////////////

////////////////code///////////////

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 10, 5, 4, 3, 2);
#define PIN_SET 8
#define PIN_DEC 1
#define PIN_INC 0
int buttonState = 0; // current state of the button
int lastButtonState = 0; // previous state of the button

#define motorpin 11
#define heaterpin 9

int startbutton = 6;
int stopbutton = 7;
unsigned long Temp = 0;
unsigned long Speed = 0;
int Sensorpin = A0;
unsigned long tempsensor = 0 ;

void setup() {

pinMode(motorpin, OUTPUT);
pinMode(heaterpin, OUTPUT);
pinMode(startbutton, INPUT_PULLUP);
pinMode(stopbutton, INPUT_PULLUP);
pinMode(PIN_INC, INPUT_PULLUP);
pinMode(PIN_DEC, INPUT_PULLUP);
pinMode(PIN_SET, INPUT_PULLUP);
lcd.begin(16, 2 );
lcd.setCursor(0, 0);
lcd.print(" Kemetch Sealer “);
delay(3000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“Speed:”);
lcd.setCursor(10, 0);
lcd.print(”%");
lcd.setCursor(0, 1);
lcd.print(“TEMP:”);
lcd.setCursor(9, 1);
lcd.print(“C”);

}

void loop() {

buttonState = digitalRead(PIN_SET); // read digital pin 2
if (buttonState != lastButtonState) {

//*****************************************************************//
if (buttonState = HIGH) {

if (PIN_INC == HIGH && PIN_DEC == LOW) {

if (Speed < 10) {
Speed ++;
delay(100);
lcd.setCursor(7, 0);
lcd.print(Speed);
}

if (PIN_INC == LOW && PIN_DEC == HIGH) {

if (Speed >= 0) {

Speed --;
lcd.setCursor(7, 0);
lcd.print(Speed);

delay(100);
}
}
}
}

//*****************************************************************//
if (buttonState = LOW) {

if (PIN_INC == HIGH && PIN_DEC == LOW) {
if (Temp < 400) {
Temp ++;
delay(100);
lcd.setCursor(6, 1);
lcd.print(Temp);
}

if (PIN_INC == LOW && PIN_DEC == HIGH) {

if (Temp >= 0) {

Temp --;

delay(100);
lcd.setCursor(6, 1);
lcd.print(Temp);
}

}
}

}
}
}

tempsensor = analogRead(A0);
unsigned long tempvalue = tempsensor * 0.48828125;

if (Temp > tempvalue) {

if ((digitalRead(startbutton) == HIGH) && (digitalRead( stopbutton) == LOW))
{

analogWrite(motorpin, (Speed * 25.5));
digitalWrite(heaterpin, HIGH);
}

if ((digitalRead(startbutton) == LOW) && (digitalRead( stopbutton) == HIGH))
{

analogWrite(motorpin, LOW);
digitalWrite(heaterpin, LOW);

}
}
}

and thats the error message .

Arduino: 1.7.10 (Windows 7), Board: “Arduino Uno”

Motor_control_for_sealer_machine_modified.ino:112:1: error: ‘tempsensor’ does not name a type

Motor_control_for_sealer_machine_modified.ino:115:1: error: expected unqualified-id before ‘if’

Error compiling.

Here is your code with the source of the error (extra } in line 104) shown in a comment. Also you need to fix the bad syntax in the if statement pointed out by jimLee (line 77).

This code now compiles (again with warnings from the LCD library).

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 10, 5, 4, 3, 2);
#define PIN_SET 8
#define PIN_DEC 1
#define PIN_INC 0
int buttonState = 0;          // current state of the button
int lastButtonState  = 0;     // previous state of the button

#define motorpin  11
#define heaterpin  9

int startbutton = 6;
int stopbutton = 7;
unsigned long Temp = 0;
unsigned long Speed = 0;
int Sensorpin = A0;
unsigned long  tempsensor = 0 ;

void setup()
{
   pinMode(motorpin, OUTPUT);
   pinMode(heaterpin, OUTPUT);
   pinMode(startbutton, INPUT_PULLUP);
   pinMode(stopbutton, INPUT_PULLUP);
   pinMode(PIN_INC, INPUT_PULLUP);
   pinMode(PIN_DEC, INPUT_PULLUP);
   pinMode(PIN_SET, INPUT_PULLUP);
   lcd.begin(16, 2 );
   lcd.setCursor(0, 0);
   lcd.print(" Kemetch Sealer ");
   delay(3000);
   lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("Speed:");
   lcd.setCursor(10, 0);
   lcd.print("%");
   lcd.setCursor(0, 1);
   lcd.print("TEMP:");
   lcd.setCursor(9, 1);
   lcd.print("C");
}

void loop()
{
   buttonState = digitalRead(PIN_SET);   // read digital pin 2
   if (buttonState != lastButtonState)
   {
      //*****************************************************************//
      if (buttonState = HIGH)
      {
         if (PIN_INC == HIGH && PIN_DEC == LOW)
         {
            if (Speed < 10)
            {
               Speed ++;
               delay(100);
               lcd.setCursor(7, 0);
               lcd.print(Speed);
            }
            if (PIN_INC == LOW && PIN_DEC == HIGH)
            {

               if (Speed >= 0)
               {

                  Speed --;
                  lcd.setCursor(7, 0);
                  lcd.print(Speed);

                  delay(100);
               }
            }
         }
      }
      
      //*****************************************************************//
      if (buttonState == LOW) // THIS WAS POINTED OUT BY  jimLee AND NEEDS 
                             // FIXING (= FOR ASSIGNEMENT == FOR COMPARE).
      {
         if (PIN_INC == HIGH && PIN_DEC == LOW)
         {
            if (Temp < 400)
            {
               Temp ++;
               delay(100);
               lcd.setCursor(6, 1);
               lcd.print(Temp);
            }

            if (PIN_INC == LOW && PIN_DEC == HIGH)
            {

               if (Temp >= 0)
               {
                  Temp --;
                  delay(100);
                  lcd.setCursor(6, 1);
                  lcd.print(Temp);
               }
            }
         }
      }
   }
   //}   THIS EXTRA } CLOSES THE LOOP FUNNCTION.  EVERY THING 
   //    AFTER THIS IS OUTSIDE OF A FUNCTION AND NOT LEGAL

   tempsensor = analogRead(A0);
   unsigned long tempvalue = tempsensor * 0.48828125;

   if (Temp > tempvalue)
   {
      if ((digitalRead(startbutton) == HIGH) && (digitalRead( stopbutton) == LOW))
      {
         analogWrite(motorpin, (Speed * 25.5));
         digitalWrite(heaterpin, HIGH);
      }

      if ((digitalRead(startbutton) == LOW) && (digitalRead( stopbutton) == HIGH))
      {
         analogWrite(motorpin, LOW);
         digitalWrite(heaterpin, LOW);

      }
   }
}

thanxx so much , i've already simulated this code in proteus but not worked . i will use the lcd library that u suggested hoping that the project works . please if u know a better code to do this job(depending on what u understood from my code ) help me . it's my first project and might be my first home business . if u wanna the pics of the proteus design i can send it to you via email or facebook to let u knw whats my project about.

by the way i have changed all the push button pinMode(......,INPUT) instead of (.........,INPUT PULL UP) according to my buttons connections in proteus

sorry , i know it's asking for too much help , but this is a matter of live or die for me .

jimLee:
if(buttonState=HIGH){ ← maybe–> if(buttonState==HIGH){

-jim lee

thnxx so much for ur rebly .

please tell me if this code needs any modifications , the project is a variable speed motor and on/off heater by a variable set temperature , i have 5 pushbuttons (PIN_SET ,PIN_DEC,PIN_INC ,startbutton,stopbutton)

PIN_SET > to choose to set variable to speed or temp
PIN_DEC > to decreament a variable (speed or temp)
PIN_INC >to increament a variable (speed or temp)
startbutton> to start the process (motor & heater) according to the already set values.
stopbutton > to stop the process

/*code/

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
#define PIN_SET 8
#define PIN_DEC 1
#define PIN_INC 0
int buttonState = 0; // current state of the button
int lastButtonState = 0; // previous state of the button

#define motorpin 11
#define heaterpin 9

int startbutton = 6;
int stopbutton = 7;
unsigned long Temp = 0;
unsigned long Speed = 0;
int Sensorpin = A0;
unsigned long tempsensor = 0 ;

void setup()
{
pinMode(motorpin, OUTPUT);
pinMode(heaterpin, OUTPUT);
pinMode(startbutton, INPUT_PULLUP);
pinMode(stopbutton, INPUT_PULLUP);
pinMode(PIN_INC, INPUT_PULLUP);
pinMode(PIN_DEC, INPUT_PULLUP);
pinMode(PIN_SET, INPUT_PULLUP);
lcd.begin(16, 2 );
lcd.setCursor(0, 0);
lcd.print(" Kemetch Sealer “);
delay(3000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“Speed:”);
lcd.setCursor(10, 0);
lcd.print(”%");
lcd.setCursor(0, 1);
lcd.print(“TEMP:”);
lcd.setCursor(9, 1);
lcd.print(“C”);
}

void loop()
{
buttonState = digitalRead(PIN_SET); // read digital pin 2
if (buttonState != lastButtonState)
{
//*****************************************************************//
if (buttonState = HIGH)
{
if (PIN_INC == HIGH && PIN_DEC == LOW)
{
if (Speed < 10)
{
Speed ++;
delay(100);
lcd.setCursor(7, 0);
lcd.print(Speed);
}
if (PIN_INC == LOW && PIN_DEC == HIGH)
{

if (Speed >= 0)
{

Speed --;
lcd.setCursor(7, 0);
lcd.print(Speed);

delay(100);
}
}
}
}

//*****************************************************************//
if (buttonState == LOW)
{
if (PIN_INC == HIGH && PIN_DEC == LOW)
{
if (Temp < 400)
{
Temp ++;
delay(100);
lcd.setCursor(6, 1);
lcd.print(Temp);
}

if (PIN_INC == LOW && PIN_DEC == HIGH)
{

if (Temp >= 0)
{
Temp --;
delay(100);
lcd.setCursor(6, 1);
lcd.print(Temp);
}
}
}
}
}
//} THIS EXTRA } CLOSES THE LOOP FUNNCTION. EVERY THING
// AFTER THIS IS OUTSIDE OF A FUNCTION AND NOT LEGAL

tempsensor = analogRead(A0);
unsigned long tempvalue = tempsensor * 0.48828125;

if (Temp > tempvalue)
{
if ((digitalRead(startbutton) == HIGH) && (digitalRead( stopbutton) == LOW))
{
analogWrite(motorpin, (Speed * 25.5));
digitalWrite(heaterpin, HIGH);
}

if ((digitalRead(startbutton) == LOW) && (digitalRead( stopbutton) == HIGH))
{
analogWrite(motorpin, LOW);
digitalWrite(heaterpin, LOW);

}
}
}