STOP LOOPING CODING

hi all

anyone pls advice

i have some trouble here

my project is automatic air conditioner remote controller.

problem is .. i dont know how to stop looping on my coding when i put temperature in range value

coding:

//loop()

if (t>=25 && t<=40);
{

delay(5000);
irsend.sendRaw(raw23,216,38);
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);

}

//

What do you want to happen when the temperature is in range ?
What do you want to happen when the temperature becomes in range ?
What do you want to happen when the temperature is not in range ?

Aizathadi:
problem is .. i dont know how to stop looping on my coding when i put temperature in range value

I don't understand what you want.

In an Arduino program the function loop() should repeat quickly and continuously.

...R

 if (t>=25 && t<=40);

oops

hi

what i want is.. ir sending one time to set the air conditoner to 23 C when temperature in range.. what happen know .. my coding are keep looping.. and keep sending ir to my air conditoner..

here is my code

if there are led myb ican use "else ... digitalwrite... low..

but know im using ir led..

and by the way im using arduino mega

#include "DHT.h"
#include <LiquidCrystal.h>
#include <IRremote.h>

#define DHTPIN 7 //Define sensor pin(pin 12)
#define DHTTYPE DHT22 //What sensor use

DHT dht(DHTPIN, DHTTYPE);//Create sensor object
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

float h=0,t=0,e=0;
const int ledPin = 13; //LED pins for temperature control
long previousMillis = 0;
long interval = 1000; //Read sensor each 2 seconds

IRsend irsend;

unsigned int raw1[210]={ 12292, 1176, 640, 1604, 668, 1572, 668, 440, 640, 464, 640, 444, 692, 364, 920, 972, 164, 260, 668, 1576, 664, 440, 668, 348, 1840, 404, 728, 376, 1624, 256, 1088, 444, 640, 1600, 640, 468, 668, 436, 784, 248, 716, 412, 720, 320, 1700, 436, 896, 1572, 640, 1604, 640, 464, 668, 368, 712, 380, 724, 392, 716, 376, 732, 344, 764, 288, 816, 376, 732, 420, 688, 460, 672, 440, 780, 284, 684, 444, 664, 1096, 21148, 400, 680, 452, 652, 416, 692, 492, 616, 400, 704, 440, 668, 420, 688, 464, 644, 464, 640, 468, 640, 468, 636, 472, 636, 468, 724, 384, 640, 468, 636, 468, 640, 464, 644, 416, 692, 468, 636, 420, 688, 412, 696, 408, 700, 400, 864, 980, 14436, 244, 1848, 592, 640, 468, 636, 472, 636, 436, 672, 468, 636, 472, 636, 496, 612, 468, 640, 464, 640, 1204, 200, 212, 628, 468, 636, 1604, 640, 1600, 640, 1600, 640, };
unsigned int raw28[211]={ 9184, 4336, 664, 1584, 664, 1584, 664, 448, 664, 444, 696, 416, 640, 472, 668, 1580, 668, 1584, 664, 1584, 664, 1584, 664, 1588, 664, 444, 664, 448, 640, 1608, 668, 444, 692, 1556, 664, 448, 668, 444, 664, 448, 692, 416, 696, 416, 692, 1556, 668, 1584, 664, 1584, 664, 444, 668, 444, 668, 444, 664, 448, 664, 444, 668, 444, 668, 444, 668, 444, 692, 416, 668, 444, 668, 444, 664, 448, 664, 448, 664, 1584, 664, 448, 664, 444, 668, 444, 696, 416, 664, 448, 664, 444, 668, 444, 696, 416, 692, 1556, 668, 444, 664, 448, 664, 444, 668, 444, 668, 444, 696, 416, 724, 1528, 664, 444, 664, 448, 664, 444, 668, 444, 696, 416, 692, 420, 664, 448, 664, 444, 668, 444, 668, 444, 664, 448, 664, 444, 640, 472, 668, 444, 664, 448, 664, 448, 664, 444, 668, 444, 692, 420, 692, 420, 664, 444, 696, 416, 640, 472, 692, 1556, 668, 444, 664, 448, 664, 444, 668, 444, 668, 444, 668, 444, 664, 448, 664, 448, 636, 472, 696, 416, 664, 1584, 668, 444, 668, 1584, 664, 444, 692, 420, 692, 420, 664, 444, 668, 444, 696, 1556, 692, 1556, 664, 1584, 664, 1584, 668, 444, 696, 1556, 692, 1556, 664, 1584, 668,};
unsigned int raw27[212]={ 9132, 1348, 400, 208, 264, 2168, 664, 1584, 664, 1584, 668, 444, 664, 444, 668, 444, 664, 448, 692, 1560, 664, 1584, 664, 1584, 664, 1584, 668, 1584, 664, 1584, 664, 1584, 664, 448, 664, 444, 668, 1584, 664, 448, 664, 444, 668, 444, 668, 444, 664, 448, 664, 1584, 668, 1580, 668, 1580, 668, 444, 668, 444, 668, 444, 664, 444, 668, 448, 664, 444, 664, 448, 668, 444, 664, 444, 668, 444, 668, 444, 668, 444, 664, 448, 664, 1584, 668, 444, 664, 444, 696, 416, 668, 444, 696, 416, 668, 440, 668, 444, 668, 444, 692, 1556, 668, 444, 668, 444, 668, 444, 668, 444, 664, 444, 668, 444, 696, 1552, 668, 444, 668, 444, 668, 440, 672, 440, 672, 440, 668, 444, 696, 416, 668, 440, 672, 440, 672, 440, 672, 440, 668, 444, 668, 444, 668, 440, 696, 416, 668, 444, 668, 444, 668, 440, 696, 416, 672, 440, 668, 444, 668, 440, 672, 440, 696, 1180, 4352, 304, 832, 444, 668, 440, 672, 444, 668, 440, 696, 416, 668, 440, 672, 1176, 1268, 244, 672, 1580, 668, 444, 668, 440, 672, 440, 696, 416, 668, 444, 668, 1580, 672, 1580, 668, 1580, 668, 440, 672, 440, 696, 1556, 668, 1580, 668, 1580, 668, };
unsigned int raw26[213]={ 9160, 4356, 668, 1584, 664, 1584, 664, 444, 668, 444, 664, 448, 664, 448, 664, 1584, 664, 1584, 664, 1584, 664, 1584, 668, 1584, 664, 444, 664, 1588, 688, 420, 664, 448, 636, 1612, 692, 420, 664, 444, 668, 444, 664, 448, 692, 420, 692, 1556, 664, 1584, 664, 1584, 664, 448, 664, 448, 660, 448, 692, 420, 640, 472, 664, 448, 688, 420, 668, 444, 664, 448, 636, 472, 640, 472, 664, 448, 640, 468, 692, 1560, 664, 444, 640, 472, 640, 472, 664, 444, 640, 472, 664, 448, 664, 448, 664, 444, 668, 444, 640, 472, 668, 444, 640, 468, 668, 444, 668, 444, 664, 448, 664, 1584, 664, 444, 668, 444, 640, 472, 640, 472, 640, 472, 636, 472, 720, 392, 664, 448, 664, 448, 636, 472, 640, 472, 640, 472, 640, 472, 636, 472, 664, 448, 692, 416, 692, 420, 668, 444, 668, 444, 664, 444, 640, 472, 668, 444, 668, 444, 640, 1608, 692, 420, 664, 444, 668, 444, 640, 472, 640, 472, 640, 468, 692, 420, 664, 448, 640, 472, 664, 444, 664, 1588, 664, 444, 668, 1584, 664, 444, 692, 420, 640, 472, 640, 472, 664, 444, 668, 1584, 692, 1556, 664, 1584, 692, 1556, 692, 1560, 692, 416, 668, 444, 668, 1580, 668,};
unsigned int raw23[214]={ 9108, 4416, 664, 1584, 640, 1612, 664, 444, 664, 448, 664, 448, 640, 468, 640, 1612, 664, 1584, 640, 1608, 668, 1584, 636, 1612, 668, 1580, 668, 1584, 664, 1584, 664, 1588, 664, 444, 640, 468, 640, 476, 636, 472, 640, 472, 640, 472, 640, 1608, 668, 1580, 668, 1584, 664, 448, 664, 444, 640, 472, 668, 444, 668, 440, 640, 472, 668, 444, 668, 444, 640, 472, 640, 468, 640, 472, 640, 472, 640, 472, 724, 1524, 664, 448, 640, 472, 640, 468, 640, 472, 640, 472, 640, 472, 720, 392, 636, 472, 640, 472, 640, 472, 640, 472, 640, 468, 640, 472, 720, 392, 640, 472, 640, 1608, 668, 444, 640, 472, 640, 472, 692, 416, 640, 472, 640, 472, 696, 416, 692, 416, 696, 416, 640, 472, 640, 472, 720, 392, 640, 468, 640, 472, 640, 472, 696, 416, 640, 472, 636, 472, 752, 360, 640, 472, 832, 276, 644, 472, 636, 476, 636, 1612, 664, 444, 640, 472, 640, 472, 696, 416, 664, 444, 640, 472, 640, 472, 696, 416, 720, 392, 640, 468, 696, 1556, 664, 448, 640, 1608, 640, 472, 640, 468, 640, 472, 696, 416, 668, 444, 696, 1552, 668, 1584, 664, 1584, 640, 472, 664, 444, 640, 472, 640, 468, 644, 1608, 640,};
unsigned int raw24[209]={ 9108, 1200, 512, 2700, 664, 1584, 640, 1608, 668, 444, 664, 448, 808, 300, 1836, 272, 304, 528, 156, 268, 636, 1612, 664, 1584, 664, 1584, 664, 1584, 640, 472, 640, 468, 640, 472, 780, 332, 808, 1016, 164, 264, 664, 444, 668, 444, 640, 320, 844, 300, 756, 444, 780, 1072, 116, 308, 640, 1612, 664, 1584, 636, 472, 724, 388, 640, 472, 640, 468, 864, 248, 752, 280, 720, 476, 2996, 332, 640, 472, 696, 396, 660, 464, 644, 1612, 664, 444, 640, 472, 640, 472, 640, 472, 636, 472, 640, 472, 724, 388, 640, 472, 640, 472, 2968, 324, 900, 248, 724, 388, 640, 472, 640, 472, 952, 284, 108, 904, 640, 472, 636, 472, 640, 472, 640, 472, 668, 444, 720, 392, 636, 472, 640, 472, 724, 348, 676, 476, 1748, 412, 808, 332, 668, 476, 776, 248, 780, 416, 640, 468, 668, 448, 636, 472, 640, 472, 640, 472, 636, 472, 640, 1612, 664, 444, 668, 444, 640, 472, 888, 208, 656, 332, 776, 472, 640, 472, 724, 344, 680, 472, 696, 420, 636, 1612, 664, 444, 664, 1584, 640, 472, 640, 472, 640, 468, 1752, 472, 640, 1608, 640, 1612, 664, 1584, 640, 1608, 668, 444, 640, 1608, 640, 472, 640, 1612, 636,};

void setup() {
lcd.begin(16, 2); //Start lcd
lcd.setCursor(0,0); //Set in position 0,0
// set the digital pin as output:
pinMode(ledPin, OUTPUT);//Change to output my pins
dht.begin();//Start DHT22 sensor
digitalWrite(ledPin,LOW);//Turn off LED
lcd.print("Tempera:");// print in lcd this word
lcd.setCursor(0,1);//Change cursor position
lcd.print("Humedad:");// print in lcd this word
pinMode(9,OUTPUT); // The library initializes pin 3 as an output
digitalWrite(9, LOW);// Since our LED is connected to pin 9, we initialize it here

}
void loop()
{
unsigned long currentMillis = millis();//time elapsed
if(currentMillis - previousMillis > interval) //Comparison between the elapsed time and the time in which the action is to be executed

previousMillis = currentMillis; //"Last time is now"

h = dht.readHumidity();//humidity value
t = dht.readTemperature();//temperature value centigrades if you want farenheit change to
e = t-2;
//t = dht.readTemperature(true);
//Below is for print data sensors in lcd
lcd.setCursor(9,0);
lcd.print(t);
lcd.setCursor(9,1);
lcd.print(h);
lcd.setCursor(15,0);
lcd.print("C");
lcd.setCursor(15,1);
lcd.print("%");

if (t>=25 && t<=40);
{
irsend.sendRaw(raw1,210,38);
delay(1000);

}

}

  if (t>=25 && t<=40);Still oops.

Please remember to use code tags when posting code.

any one please

........

See replies #3 and #5

void setup() {
lcd.begin(16, 2);              //Start lcd
lcd.setCursor(0,0);            //Set in position 0,0
// set the digital pin as output:
pinMode(ledPin, OUTPUT);//Change to output my pins
dht.begin();//Start DHT22 sensor
digitalWrite(ledPin,LOW);//Turn off LED
lcd.print("Tempera:");// print in lcd this word
lcd.setCursor(0,1);//Change cursor position
lcd.print("Humedad:");// print in lcd this word
pinMode(9,OUTPUT); // The library initializes pin 3 as an output
digitalWrite(9, LOW);// Since our LED is connected to pin 9, we initialize it here


   








}
void loop()
{

This is just plain stupid. The ONLY excuse for putting the { on the same line as the function/statement that holds any water is that it saves real-estate. Then putting forty-leven blank lines in the function makes no sense.

Jamming everything up against the left edge, instead of properly indenting the code, makes no sense.

I'm not even going to attempt to read that code.

Using Tools + Auto Format, reasonable white space, and code tags costs nothing, but it does keep you from looking like you don't give a damn.

Aizathadi:
what i want is.. ir sending one time to set the air conditoner to 23 C when temperature in range.. what happen know .. my coding are keep looping.. and keep sending ir to my air conditoner..

here is my code

First, to make it easy for people to help you please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum

If you only want to send a message once then create a variable to count how many times the message has been sent.

...R