Show Posts
Pages: 1 [2] 3 4
16  Using Arduino / Programming Questions / Re: DS18B20 - temperature sensor code Help Request SOLVED on: April 19, 2012, 10:26:43 pm
That did the trick - putting the temp code in the else area

Thanks to all for the help!!

Code working fine!!

LCD DISPLAY - i2c 20/4
3 SENSORS - ds18B20
2 LEDS - 1 for red LED for high temp alarm and another LED for normal  temperature


Joe
17  Using Arduino / Programming Questions / Re: DS18B20 - temperature sensor code Help Request on: April 19, 2012, 09:02:12 am
1. As suggested, I changed the variable names as suggested temp0 and temp1.

2.Also, added  the else statement to isolate each condition.
This has cleared up the LED blinking problem  - on Temp0 -GREAT


3. PROBLEM:

When Temp0 > 29 LED0 turns on steady (GOOD) but LCD  flashes between the word "Temp0" and "Alarm0"  - Not Good!

How do I correct Flashing LCD problem?  Suggestions ?
----------------------------------------------------------------

When Temp1 > 25 LED1 turns on steady (GOOD)  and "Alarm1" is displayed steady - no flashing - Good!
This is how Temp0 should work




LATEST CODE BELOW:

Code:
#include <OneWire.h>

#include <DallasTemperature.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>

LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27  16/2
// LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27  20/


// pin connected to sensor
int tempPin = 2;
// define the onewire obj needed for connecting to onewire components
OneWire oneWire(tempPin);
// define dallas obj, makes it easier to read temp
DallasTemperature tempSens(&oneWire);

DeviceAddress insideThermometer = {
  0x28, 0x25, 0x33, 0xDC, 0x03, 0x00, 0x00, 0x7E };
DeviceAddress outsideThermometer = {
  0x28, 0x67, 0x3D, 0xDC, 0x03, 0x00, 0x00, 0xC7 };


void setup() {
  // set up the serial console
  Serial.begin(9600);
  pinMode(7, OUTPUT); //pin selected to control OVER TEMP LED red temp0  
  pinMode(8, OUTPUT); //pin selected to control OVER TEMP LED green temp1

  // digitalWrite(7, LOW);


  lcd.init(); // initialize the lcd
  lcd.backlight();
  //lcd.begin(16,2); // columns, rows. use 16,2 for a 16x2 LCD, etc.
  lcd.clear(); // start with a blank screen



  // initialise the temp sensor

    tempSens.begin();
  // set the resolution to 10 bit (good enough?)
  tempSens.setResolution(insideThermometer, 10);
  tempSens.setResolution(outsideThermometer, 10);

}

void loop() {
  // get the current temperature

  tempSens.requestTemperatures();

  // get the temperature in centigrade
  // index 0 as multiple temp sensors can be connected on same bus

    float temp0 = tempSens.getTempCByIndex(0);

  Serial.print("TEMP0 = ");
  Serial.print(temp0);
  lcd.setCursor(0,0);
  lcd.print("TEMP0 = ");
  lcd.print(temp0);
  delay(200);

  float temp1 = tempSens.getTempCByIndex(1);
  lcd.setCursor(0,1);
  lcd.print("TEMP1 = ");
  lcd.print(temp1);
  Serial.print("TEMP1= ");
  Serial.print(temp1);
  //delay(200);

  if  (temp0  > 29) //sensor0 temp0
  {
    lcd.setCursor(0,0);
    Serial.println("Alarm0= ");
    lcd.print("Alarm0= ");
    lcd.setCursor(8,0);
    Serial.println(temp0);
    lcd.print(temp0);
    digitalWrite(7,HIGH); //LED0 /FAN0
  }
else
  {
    digitalWrite(7,LOW);
  
  }


  if  (temp1  > 25) //sensor 1 temp1
  {
    lcd.setCursor(0,1);
    Serial.println("Alarm1= ");
    lcd.print("Alarm1= ");
    lcd.setCursor(8,1);
    Serial.println(temp1);
    lcd.print(temp1);
    digitalWrite(8,HIGH); //LED1 /FAN1
  }
  else
  {
    
    digitalWrite(8,LOW);
  }









}






18  Using Arduino / Programming Questions / Re: DS18B20 - temperature sensor code Help Request on: April 18, 2012, 09:40:26 pm
LATEST CODE -  with 2 leds 1 for each alarm

With no alarm lcd displays: ALL GOOD
----------------------------------------
TEMP0 = 22.25 ( CURRENT TEMP)
TEMP1 = 22.25 ( CURRENT TEMP)
----------------------------------------

When alarm occurs on temp1 LCD displays: ALL GOOD
---------------------------------------
TEMP0 = 22.25 ( CURRENT TEMP)
Alarm1 = 29.50 ( CURRENT TEMP)   plus Led is ON Steady
---------------------------------------


When alarm occurs on temp0 LCD displays:
---------------------------------------
Alarm0 = 25.50 ( CURRENT TEMP)  "Alarm0" is flashing between Temp0 and Alarm0  and LED  is blinking. BAD
TEMP1 = 22.50 ( CURRENT TEMP)
---------------------------------------

Code:
#include <OneWire.h>

#include <DallasTemperature.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>

LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27  16/2
// LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27  20/


// pin connected to sensor
int tempPin = 2;
// define the onewire obj needed for connecting to onewire components
OneWire oneWire(tempPin);
// define dallas obj, makes it easier to read temp
DallasTemperature tempSens(&oneWire);

DeviceAddress insideThermometer = {
  0x28, 0x25, 0x33, 0xDC, 0x03, 0x00, 0x00, 0x7E };
DeviceAddress outsideThermometer = {
  0x28, 0x67, 0x3D, 0xDC, 0x03, 0x00, 0x00, 0xC7 };


void setup() {
  // set up the serial console
  Serial.begin(9600);
  pinMode(7, OUTPUT); //pin selected to control OVER TEMP LED red temp0 
  pinMode(8, OUTPUT); //pin selected to control OVER TEMP LED green temp1
 
  // digitalWrite(7, LOW);


  lcd.init(); // initialize the lcd
  lcd.backlight();
  //lcd.begin(16,2); // columns, rows. use 16,2 for a 16x2 LCD, etc.
  lcd.clear(); // start with a blank screen



  // initialise the temp sensor

    tempSens.begin();
  // set the resolution to 10 bit (good enough?)
  tempSens.setResolution(insideThermometer, 10);
  tempSens.setResolution(outsideThermometer, 10);

}

void loop() {
  // get the current temperature

  tempSens.requestTemperatures();

  // get the temperature in centigrade
  // index 0 as multiple temp sensors can be connected on same bus

    float t = tempSens.getTempCByIndex(0);

  Serial.print("TEMP0 = ");
  Serial.print(t);
  lcd.setCursor(0,0);
  lcd.print("TEMP0 = ");
  lcd.print(t);
  delay(200);

  float t1 = tempSens.getTempCByIndex(1);
  lcd.setCursor(0,1);
  lcd.print("TEMP1 = ");
  lcd.print(t1);
  Serial.print("TEMP1= ");
  Serial.print(t1);
  //delay(200);

  if  (t  > 29) //sensor0
  {
    lcd.setCursor(0,0);
    Serial.println("Alarm0= ");
    lcd.print("Alarm0= ");
    lcd.setCursor(8,0);
    Serial.println(t);
    lcd.print(t);
    digitalWrite(7,HIGH);
  }

  if  (t1  > 25) //sensor 1
  {
    lcd.setCursor(0,1);
    Serial.println("Alarm1= ");
    lcd.print("Alarm1= ");
    lcd.setCursor(8,1);
    Serial.println(t1);
    lcd.print(t1);
    digitalWrite(8,HIGH);
  }
  else
  {
    digitalWrite(7,LOW);
    digitalWrite(8,LOW);
  }









}




19  Using Arduino / Programming Questions / Re: DS18B20 - temperature sensor code Help Request on: April 18, 2012, 09:34:36 pm
I tried  it using pin 8  ( change code accordingly) - same results.

I am using a 1k resistor for the led -

1. I decided to replace the led in the same spot.
    Now led  is not blinking and it stays on during a Temp1- alarm1 and goes off with no alarm1 -PERFECT


2. I added another led for Temp0

3. When Temp0 goes into alarm0 mode -  LED still blinks light - Not good

4. The lcd display also flashes Temp0 to Alarm0 back and forth - Not good
20  Using Arduino / Programming Questions / Re: DS18B20 - temperature sensor code Help Request on: April 18, 2012, 08:45:46 pm
WildBill,

latest code:

With no alarm lcd displays:
----------------------------------------
TEMP0 = 22.25 ( CURRENT TEMP)
TEMP1 = 22.25 ( CURRENT TEMP)
----------------------------------------

When alarm occurs on temp1 LCD displays:
---------------------------------------
TEMP0 = 22.25 ( CURRENT TEMP)
Alarm1 = 29.50 ( CURRENT TEMP)   plus Led is blinking
---------------------------------------


When alarm occurs on temp0 LCD displays:
---------------------------------------
Alarm0 = 25.50 ( CURRENT TEMP)   ---- but  "Alarm0" is blinking and led is not blinking
TEMP1 = 22.50 ( CURRENT TEMP)
---------------------------------------



Code:
#include <OneWire.h>

#include <DallasTemperature.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>

LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27  16/2
// LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27  20/


// pin connected to sensor
int tempPin = 2;
// define the onewire obj needed for connecting to onewire components
OneWire oneWire(tempPin);
// define dallas obj, makes it easier to read temp
DallasTemperature tempSens(&oneWire);

DeviceAddress insideThermometer = {
  0x28, 0x25, 0x33, 0xDC, 0x03, 0x00, 0x00, 0x7E };
DeviceAddress outsideThermometer = {
  0x28, 0x67, 0x3D, 0xDC, 0x03, 0x00, 0x00, 0xC7 };


void setup() {
  // set up the serial console
  Serial.begin(9600);
  pinMode(7, OUTPUT); //pin selected to control OVER TEMP LED
  // digitalWrite(7, LOW);


  lcd.init(); // initialize the lcd
  lcd.backlight();
  //lcd.begin(16,2); // columns, rows. use 16,2 for a 16x2 LCD, etc.
  lcd.clear(); // start with a blank screen



  // initialise the temp sensor

    tempSens.begin();
  // set the resolution to 10 bit (good enough?)
  tempSens.setResolution(insideThermometer, 10);
  tempSens.setResolution(outsideThermometer, 10);

}

void loop() {
  // get the current temperature

  tempSens.requestTemperatures();

  // get the temperature in centigrade
  // index 0 as multiple temp sensors can be connected on same bus

    float t = tempSens.getTempCByIndex(0);

  Serial.print("TEMP0 = ");
  Serial.print(t);
  lcd.setCursor(0,0);
  lcd.print("TEMP0 = ");
  lcd.print(t);
  delay(500);

  float t1 = tempSens.getTempCByIndex(1);
  lcd.setCursor(0,1);
  lcd.print("TEMP1 = ");
  lcd.print(t1);
  Serial.print("TEMP1= ");
  Serial.print(t1);
  //delay(200);

  if  (t  > 29) //sensor0
  {
    lcd.setCursor(0,0);
    Serial.println("Alarm0= ");
    lcd.print("Alarm0= ");
    lcd.setCursor(8,0);
    Serial.println(t);
    lcd.print(t);
    digitalWrite(7,HIGH);
  }

  if  (t1  > 25) //sensor 1
  {
    lcd.setCursor(0,1);
    Serial.println("Alarm1= ");
    lcd.print("Alarm1= ");
    lcd.setCursor(8,1);
    Serial.println(t1);
    lcd.print(t1);
    digitalWrite(7,HIGH);
  }
  else
  {
    digitalWrite(7,LOW);
  }









}




21  Using Arduino / Programming Questions / Re: DS18B20 - temperature sensor code Help Request on: April 18, 2012, 07:29:16 pm
Wildbill,

While monitor the serial port:

With no alarm:

i get temp0 =21.22    temp1= 22.75  - looks good


Wth an alarm (temp over 25): LED BLINKING

TEMP0 = 22.00TEMP1= 27.25Alarm1= 27.25

TEMP0 = 22.00TEMP1= 27.00Alarm1= 27.00

TEMP0 = 22.00TEMP1= 27.00Alarm1= 27.00

TEMP0 = 21.75TEMP1= 26.75Alarm1= 26.75

until it reaches temp of 25 then  - alarm goes off  / led shuts off

i get temp0 =21.00    temp1= 25.00  - looks good

Still cannot seem to figure a way to stop the blink led and make it steady when it alarms.

Also when i try to change the if  (t1 > 25)  to if  (t1 => 25) i get an error - was trying to  change Alarm if temp is = to or greater than 25
22  Using Arduino / Programming Questions / Re: DS18B20 - temperature sensor code Help Request on: April 18, 2012, 07:14:07 pm
Willbill,

Yep, -the removal of the" ln"  got rid of the extra weird characters at the end of the temperatures.. lcd now displays clean temps

Still trying to address the LED blinking problem when i get an alarm
23  Using Arduino / Programming Questions / Re: DS18B20 - temperature sensor code Help Request on: April 18, 2012, 06:56:50 pm
Hmm, MarkT,

Maybe, A simpler approach like the code below would help the progress

1.  This displays TEMP0 = ACTUAL TEMP on lcd line 0 and TEMP1 = ACTUAL TEMP on lcd line 1  -- however i see the 2 fields to the right of the  temperature filled with weird characters, but the temps are good
2. When tempsensor1 goes above 25 , i get Alarm1 on the lcd display - good

3. Led goes on when an alarm on temp1 occurs but it blinks - it needs to be on only....


Any code suggestions , example to clear these issues would be appreciated

Joe



Code:
#include <OneWire.h>

#include <DallasTemperature.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>

LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27  16/2
// LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27  20/


// pin connected to sensor
int tempPin = 2;
// define the onewire obj needed for connecting to onewire components
OneWire oneWire(tempPin);
// define dallas obj, makes it easier to read temp
DallasTemperature tempSens(&oneWire);

DeviceAddress insideThermometer = {
  0x28, 0x25, 0x33, 0xDC, 0x03, 0x00, 0x00, 0x7E };
DeviceAddress outsideThermometer = {
  0x28, 0x67, 0x3D, 0xDC, 0x03, 0x00, 0x00, 0xC7 };


void setup() {
  // set up the serial console
  Serial.begin(9600);
  pinMode(7, OUTPUT); //pin selected to control OVER TEMP LED /fan off
  digitalWrite(7, LOW);


  lcd.init(); // initialize the lcd
  lcd.backlight();
  lcd.clear(); // start with a blank screen



  // init the temp sensor
  tempSens.begin();

  // set the resolution to 10 bit
  tempSens.setResolution(insideThermometer, 10);
  tempSens.setResolution(outsideThermometer, 10);

}

void loop() {
  // get the current temperature
  tempSens.requestTemperatures();

  // get the temperature in centigrade
  // index 0 as multiple temp sensors can be connected on same bus

  float t = tempSens.getTempCByIndex(0); / first sensor 0
  Serial.print("TEMP0 = ");
  Serial.println(t);
  lcd.setCursor(0,0);
  lcd.print("TEMP0 = ");
  lcd.println(t);  //print sensor0 temperature
  delay(100);

  float t1 = tempSens.getTempCByIndex(1);
  lcd.setCursor(0,1);
  lcd.print("TEMP1 = ");
  lcd.println(t1); // print sensor 1 temperature to lcd
  Serial.print("TEMP1= ");
  Serial.println(t1);
  {
//------------------------------------conditions-----------------------
  
    if  (t1 > 25) // IF TEMP ON SENSOR1 IS GREATER THAN 25  set alarm and turn on led / fan
{
    lcd.setCursor(0,1);
    lcd.print("Alarm1= ");
    lcd.setCursor(0,2);
    lcd.println(t1);
    digitalWrite(7,HIGH);
  }
else
{
digitalWrite(7,LOW); // KEEP LED / FAN OFF
}

}


}


24  Using Arduino / Programming Questions / Re: DS18B20 - temperature sensor code Help Request on: April 18, 2012, 06:03:34 pm
code checks  if there is an alarm:

Code:
if (sensors.hasAlarm()) // check to see if there is an alarm
  {
    lcd.setCursor(0,0);
    lcd.print(" HighTemp Alarm"); // print to lcd there is an alarm
    digitalWrite(7, HIGH); // turn on over-temp light / fan
25  Using Arduino / Programming Questions / Re: DS18B20 - temperature sensor code Help Request on: April 18, 2012, 05:52:57 pm
The error testing code - does not affect the end goal.... so it is not an issue. (just pretend its not there)

Joe
26  Using Arduino / Programming Questions / Re: DS18B20 - temperature sensor code Help Request on: April 18, 2012, 05:15:43 pm
yep - its crude, but  - 127  indicates there is no device and it works - if i unplug the sensor it displays an error - letting me know there is something wrong with that specific sensor or line.


As for getting the temperature and testing it, well obviously that's the problem but figuring out the code to do it is another. 
If i knew how to get the temp, or its variable then i could probably work from there.

Anyone else who can help with some code to get me started?

Thanks
joe
27  Using Arduino / Programming Questions / DS18B20 - temperature sensor code Help Request on: April 18, 2012, 04:12:53 pm
Greetings,

I recently purchased a few Temperature sensors - DS18B20.  I am using an uno r3
I found some code and modified it to display an alarm and to display on an LCD.

1. I  have the code sensing 2 DS18B20 temp sensors (the temp readings are good) and it is displaying the temperature on an lcd 16/2.
2. I  have managed  to figure out how to display on the LCD when an over-temp occurs and to turn on a led but it is not working the way I want it to.

PROBLEM:

1. The code below results in the word "ALARM" on my lcd when over temp occurs but my over temp LED blinks, instead of being on steady during the alarm. (it is wired to a relay which  turns on a fan, so it must not blink during the alarm period, as the fan must be on continuous to cool down the over-temp device and preferably stay on for at least a minute after temp returns to normal)

2. I have 2 temp sensors , i would like to be able to  Display which Sensor has the alarm and display it on the LCD (during the alarm period.)

Help figuring out the code would be appreciated
Thanks
joe
---------------------------------

Code:
#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>

LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27  16/2
// LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27  20/4

// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

DeviceAddress insideThermometer = {
  0x28, 0x25, 0x33, 0xDC, 0x03, 0x00, 0x00, 0x7E };
DeviceAddress outsideThermometer = {
  0x28, 0x67, 0x3D, 0xDC, 0x03, 0x00, 0x00, 0xC7 };


void setup(void)
{
  pinMode(7, OUTPUT); //pin selected to control OVER TEMP LED / fan

  // Start up the library
  sensors.begin();
  // set the resolution to 10 bit (good enough?)
  sensors.setResolution(insideThermometer, 10);
  sensors.setResolution(outsideThermometer, 10);

  // alarm when temp is higher than 28C
  sensors.setHighAlarmTemp(insideThermometer, 28);

  // alarm when temp is lower than -10C
  sensors.setLowAlarmTemp(insideThermometer, -10);

  // alarm when temp is higher than 26C
  sensors.setHighAlarmTemp(outsideThermometer, 26);

  // alarm when temp is lower than 15C
  sensors.setLowAlarmTemp(outsideThermometer, 15);

  lcd.init(); // initialize the lcd
  lcd.backlight();
  lcd.clear(); // start with a blank screen
}

void printTemperature(DeviceAddress deviceAddress) // DISPLAY ERROR IF DEVICE IS NOT FOUND
{
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC == -127.00) {
    lcd.print("Error");
  }
  else
  {
    lcd.print(tempC);
    lcd.print("/");
    lcd.print(DallasTemperature::toFahrenheit(tempC));
  }
}

void loop()
{
  delay(200);
  sensors.requestTemperatures();
  if (sensors.hasAlarm()) // check to see if there is an alarm
  {
    lcd.setCursor(0,0);
    lcd.print(" HighTemp Alarm");
    digitalWrite(7, HIGH); // turn on over-temp light
  }
  // call alarm handler function defined by sensors.setAlarmHandler
  // for each device reporting an alarm
  sensors.processAlarms();

  if (!sensors.hasAlarm())
  {
    // if no alarm just print out the current temperature
    //  printTemperature(insideThermometer);
    //  printTemperature(outsideThermometer);

    lcd.setCursor(0,0);
    lcd.print("In: ");
    printTemperature(insideThermometer);
    lcd.setCursor(0,1);
    lcd.print("Out: ");
    printTemperature(outsideThermometer);
    digitalWrite(7, LOW);// overtemp light off
  }


}


28  Using Arduino / Programming Questions / Re: Function was not declared in this scope - compile error on: March 06, 2012, 11:31:11 pm
Is there an easy method / logic  on how to keep track  or determine when and where open { and } are placed? 

Joe
29  Using Arduino / Programming Questions / Re: Function was not declared in this scope - compile error on: March 06, 2012, 10:50:44 pm
Thanks,

I knew i lost the { somewhere but could not match them up..

Joe
30  Using Arduino / Programming Questions / Function was not declared in this scope - compile error on: March 06, 2012, 07:50:01 pm
Code:


/*-----( Import needed libraries )-----*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
/*-----( Declare Constants )-----*/
/*-----( Declare objects )-----*/
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27
/*-----( Declare Variables )-----*/
#include <SPI.h>
#include <Ethernet.h>


byte mac[] = {
  0x90, 0xA2, 0xDA, 0x00, 0xCD, 0x4E
}; //physical mac address
byte ip[] = {
  192, 168, 1, 139
}; // ip in lan
byte gateway[] = {
  192, 168, 1, 1
}; // internet access via router
// byte subnet[] = {255, 255, 255, 0 }; //subnet mask

IPAddress dns(204,117,214,110); // OpenDNS IP

EthernetServer server(90); //server port


// DECLARE

String readString;
#define TSTAT 12    
#define FAN 13    
#define TEMP 0      
#define PUMP 11    
#define LITE 10    
const long ONE_SECOND = 1000;   //DEFINE ONE SECOND
const long ONE_MINUTE = 60 * ONE_SECOND;   //DEFINE ONE MINUTE
const long ONE_HOUR = 60 * ONE_MINUTE;     //DEFINE ONE HOUR

int T = 0;    //ANALOG READ TEMP
int temp = 0; //ACTUAL TEMP
int tstat = LOW;    //THERMOSTAT STATE VARIABLE

void setup()
{

  // START  Ethernet
  //Ethernet.begin(mac, ip, gateway, subnet);
  Ethernet.begin(mac, ip, gateway,dns);
  server.begin();


  pinMode(TSTAT, INPUT);
  pinMode(FAN, OUTPUT);
  pinMode(TEMP, INPUT);
  pinMode(PUMP, OUTPUT);
  pinMode(LITE, OUTPUT);
  pinMode(8, OUTPUT); //pin selected to control
  pinMode(9, OUTPUT); //pin selected to control FAN

  //enable serial data print  FOR TESTING ON Serial monitor
  Serial.begin(9600);
}

void loop()
{
  // Create a client connection
  EthernetClient client = server.available();

  // If someone connects to the server...
  if (client)
  {

    // Create a variable to hold whether or not we have received a blank
    // line from the web browser
    boolean current_line_is_blank = true; //new
    while (client.connected())
    {
      lcd.clear();
      lcd.print("CONNECTED!");
      lcd.blink();
      // If the client has sent us some data...

      if (client.available())
      {

        // Keep the last letter of whatever they sent us
        char c = client.read();

        //read char by char HTTP request
        if (readString.length() < 100)
        {

          //store characters to string
          readString += c;
          //Serial.print(c);


          digitalWrite(4, HIGH); // turn on "connected" LED


          // If we've gotten to the end of the line (received a newline
          // character) and the line is blank, the http request has ended,
          // so we can send a reply

          if (c == '\n' && current_line_is_blank)
          {     


            client.println("HTTP/1.1 200 OK"); //send new page
            client.println(F("Content-Type: text/html"));
            client.println();
            // ------------------------------------------------
            client.println();
            client.print(F("<body style=background-color:BLACK>")); //set background to BLACK
            client.println(F("<META HTTP-EQUIV=REFRESH CONTENT=35 URL=>"));         
            // client.println(F("<META HTTP-EQUIV=REFRESH CONTENT=5; url=>"));
            client.println(F("<HTML>")); 
            client.print(F("<HEAD>")); 
            client.println(F("<center>"));
            client.println(F("<font color=’green’><h1>INTERNET -- CONTROL </font></h1>/"));//send first heading
            client.println(F("<hr />"));
            client.println(F("<font color=’#0D8112’ size=’5′> "));
            client.println(F("</center>"));

            //if HTTP request has ended

            if (c == '\n' && current_line_is_blank)
            {
              ///////////////
              Serial.println(readString); //print to serial monitor for debugging


                if(readString.indexOf("off8") >0)//checks for off  reading string from Ethernet web form button
              {
                digitalWrite(8, LOW);    // set pin 8 low
                digitalWrite(9, LOW); //FAN
                Serial.println("Led 8 Off"); // blue led

              }

              if(readString.indexOf("sen11") >0)//checks for sensor loop test
              {
                heat();// goto heat function

              }   

              // radiobuttons

              client.print(F("<form method=get name=LED>"));
              client.println(F("<button name=sen11 value=1 type=submit style=font-weight:bold;color:red;height:50px;       width:60px>sen</button>"));
              client.println("</center>"); 
              client.println("</form>"); // new
              client.println(F("<hr />"));  // print a header on webpage ---------------------

            }
            client.println("<center>");

            client.println(F("<hr />"));
            client.println(F("</body></html>"));


            //stopping client

            client.stop();

            digitalWrite(4, LOW); // turn OFF "connected" LED
            delay(2000);
            readString="";

            // THIS IS A TEST FUNCTION  //

            void heat()
            {
              temp = analogRead(TEMP); //READ TEMP
              Serial.println(temp);     //PRINT TEMP FOR DIAG
              delay(250);   //WAIT 1/4 SECOND
              tstat = digitalRead(TSTAT);     //READ THERMOSTAT STATE
              if (tstat == HIGH) // IF THERMOSTAT CALLS FOR HEAT
              {
                digitalWrite(FAN, HIGH);      //TURN FAN ON
              }
              else    //IF THERMOSTAT DOESNT CALL FOR HEAT
              {
                digitalWrite(FAN, LOW); //TURN FAN OFF
                digitalWrite(PUMP, LOW);
                return;
              }
              if  (temp > 475)    
              {
                coilWarmup;
              }
            }
          }
        }
      }   
    }
  }
}
--------------------------------------------------------------------------------------
I am attempting to learn how incorporate a function into my code.
The Ethernet part all works fine and the button displays the correct code when clicked in the web page

I setup a web button  which sends a sen11 code and if so then it should jump to the heat function
The Ethernet part all works fine.


I cant seem to get the code to jump/go to my void [u]heat function[/u]

[u]Compile error  - heat was not declared in this scope[/u]

How do i get rid of this...  ?

Thanks
Joe
Pages: 1 [2] 3 4