Show Posts
Pages: 1 2 3 [4]
46  Using Arduino / Programming Questions / Display IP of current TCP connection on serial LCD on: February 17, 2012, 06:52:40 pm
I have put together a web server which turns  items on an off , photocell etc -  works fine


I am now trying to add the ability to see any ip that is  currently connected to my server

ON THE SERIAL LCD: i would like to:

1. LINE 1 Display  - "CONNECTED"  -
2. LINE 2 Display  - IP number  - ??

I have looked around and cant seem to find a method to display the ip

Help,
Joe

47  Using Arduino / Programming Questions / Re: I Get Only initialized variables can be placed into program memory area Warning on: February 12, 2012, 01:49:46 pm
Jantje,

I went to the other post....hmmm - looks like it is just a warning and does not affect operation.

Hopefully it actually does put my clientprint input command buttons into pgm mem


Thanks

Joe
48  Using Arduino / Programming Questions / Trying to turn off a 4 devices and their status f lags with 1 input button on: February 12, 2012, 01:41:55 pm
Code:
// declare variables

int     ledPin = 6;                // LED1
int     heatpin = 7;               // ANTENNA
int     aedpin = 5;                // LED3  
int     fedpin = 8;                // fE PWR
int     medpin = 9;                // me - anolog pin 9 for fan control
int     sensorPin = A0;            // analog in 0 forlight sense
int     sensorValue = 0;           // integer for the analog sensor
int     PIRstate = 0;              // variable for PIR sensor status
int     PIR = 2;                   // PIR sensor is connected to digital pin 2
int     motorlevel = 0;                // motor
String  readString = String(30);   // string for fetching data from address
boolean LEDON = false;             // LED1 status flag
boolean HEDON = false;             // ANTENNA status flag  
boolean AEDON = false;             // led3 status AE
boolean FEDON = false;             // power FE pin status
boolean MEDON = false;            // status off
boolean MEDON1 = false;            //MED SPEED STATUS ON
boolean PEDON = false;              // all devices status off


void setup()
{    
  
  Ethernet.begin(mac, ip, gateway, subnet ); //start Ethernet

  pinMode(ledPin, OUTPUT); //Set pin 6 to output
  pinMode(heatpin, OUTPUT); // set pin 7 to output
  pinMode(aedpin, OUTPUT); // set pin 5 to output
  pinMode(fedpin, OUTPUT); // set pin 8 to output
  pinMode(PIR, INPUT); // set pir to input
  pinMode(medpin, OUTPUT); // set pin a3 to output
  
  sensorValue = analogRead(sensorPin);
  }
[code]  
void loop()

 EthernetClient client = server.available();  // Create a client connection
  
  if (client) {
    boolean current_line_is_blank = true; //new
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // if we've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // send a reply
        
        if (readString.length() < 30) { //read char by char HTTP request
          readString.concat(c);
        } //store characters to string
// HTML Code  

if (c == '\n' && current_line_is_blank) {
          
          // HTML Code
          client.println(F("HTTP/1.1 200 OK")); //output HTML data starting with standard header
          client.println(F("Content-Type: text/html"));
          client.println();
          client.print(F("<body style=background-color:BLACK>")); //set background to BLACK

          // Auto refresh webpage every 60 seconds
          client.println(F("<META HTTP-EQUIV=REFRESH CONTENT=60 URL=>"));
          client.println("<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("</center>");
          motorlevel = 0;
      }  
  //indexOf("L=")

        if (c == '\n') { //if HTTP request has ended

          
          int Le = readString.indexOf("L="); //led here is a key component of where
          int He = readString.indexOf("H="); //the status is being read by the arduino
          int Ae = readString.indexOf("A=");
          int Fe = readString.indexOf("F=");
          int Me = readString.indexOf("M="); //motor / fan
          int Pe = readString.indexOf("P="); //master all OFF

     // Check if anything  should be lighted or turned on

            if (Le > 1){

            if (readString.substring(Le,(Le+3)) == "L=1") { //led has to be turned ON
              digitalWrite(ledPin, HIGH); // set the LED on
              
              LEDON = true;
            }

            if (readString.substring(Le,(Le+3)) == "L=0") {
              //led has to be turned OFF
              digitalWrite(ledPin, LOW); // set the LED OFF
              
              LEDON = false;
            }
          }

// all power to off check

if (Pe > 1){

           if (readString.substring(Pe,(Pe+3)) == "P=0") { //ALL OFF
            motorlevel = 0;
            analogWrite(medpin, motorlevel); // set the LED1 off
            digitalWrite(ledPin, LOW); // set the LED OFF
            digitalWrite(heatpin, LOW); // set the heat OFF
           digitalWrite(aedpin, LOW); // set the ANT OFF
           digitalWrite(fedpin, LOW); // set the PWR OFF
           PEDON = true;
            
            }  }
           client.print(F("<form method=get name=LED>"));
           client.print(F("<input type='radio' name='L' value='1'>LED1 ON<br>"));
           client.print(F("<input type='radio' name='L' value='0'>LED1 OFF<br><br>"));
           client.print(F("<input type='radio' name='P' value='0'>ALL OFF<br><br>"));
           client.println(F("<input type=submit value=submit></form>"));
           client.println(F("<hr />"));


// DETERMINE WHAT STATUS TO PRINT  
        
          client.print(F("<font size=’5′>LED1 status: "));
          if (LEDON == true) {
            client.println(F("<font color='#FF0000' size=’5′>ON</font>")); //red

          }
          else {
            client.println(F("<font color='#0099FF' size=’5′>OFF</font>")); //blue

          }

// check for all off status condition, if so turn all status flags  to off
    
           if (PEDON == true) {  
                
           LEDON = false;             // LED1 status off
           HEDON = false;             // ANTENNA status off
           AEDON = false;             // led3 status AE off
           FEDON = false;             // power FE pin status off
            MEDON = false;
            MEDON1 = false;            // off  
            
           client.println(F("<font color='#0099FF' size=’5′>OFF</font>")); //blue


           }  



1. code is used to turn on /off several devices by using the input button commands - this works
I did not include all the device code as it might be to long to post


Problem:
 I am trying to add another input command which would turn all devices and their status off at once.

Joe

[/code]
49  Using Arduino / Programming Questions / I Get Only initialized variables can be placed into program memory area Warning on: February 12, 2012, 01:12:04 pm
Code:
client.print(F("<input type='radio' name='L' value='1'>LED1 ON<br>"));



On the verbose compile info area I get this:

warning: only initialized variables can be placed into program memory area

Is the code above incorrect... and I cannot use F() on input type commands the problem?
I was under the impression i could use this on all client print type commands to save ram memory....

Thanks for any Help

Joe
50  Using Arduino / Programming Questions / Re: When using analogWrite output only goes high 255 or low 0 -SOLVED on: February 09, 2012, 08:50:08 am
Thanks for the pointer Nick,
 
I switched the pin to  pin 9,  modified int to = pin 9 and its working fine now.

I had it plugged in an Analog input......pin...oops...

Joe
51  Using Arduino / Programming Questions / Re: When using analogWrite output only goes high 255 or low 0 -SOLVED on: February 08, 2012, 11:27:05 pm
 int     medpin = A5; //analog
 int     motorlevel = 0;                // motor

 pinMode(medpin, OUTPUT); // set pin a5 to output


//lets check if anything  should be turned on
//  - Check the value of M and if it is =1 then turn motor / fan on full (255)  or if M is =0 turn fan on mid speed (110)
        
 if (Me > 1){

            if (readString.substring(Me,(Me+3)) == "M=1") { //motor has to be turned ON
              motorlevel = 255; / full  max
              analogWrite(medpin, motorlevel); // set the motor on
            
               }

            else if (readString.substring(Me,(Me+3)) == "M=0") {
            
              motorlevel = 110;  //motor  should be set to or mid speed / dim
              analogWrite(medpin,motorlevel); // set the motorLED mid speed
              
            
            }
          }
                              
                  // HTML CODE

           client.print(F("<form method=get name=LED>"));
          
           client.print(F("<input type='radio' name='M' value='1'>FAN HIGH<br>"));       // MAKE FAN GO FULL SPEED
           client.print(F("<input type='radio' name='M' value='0'>FAN MED<br><br>"));  // MAKE FAN GO HALF SPEED
           client.println(F("<input type=submit value=submit></form>"));
           client.println(F("<hr />"));
          
          
          
PROBLEM:

The above code turns the fan / motor on   or off  but does not make it go mid speed.... when i look at the voltage at the analog out pin 5 it goes to 4.92v  if M=1

but when M= 0  and the motorvalue gets set to 110 - the voltages stays the same .
If i set motorvalue to 0 or a very low figure then the voltage drops to 0.

What gives?
Joe      
52  Using Arduino / Programming Questions / HTML INPUT BUTTON - RANGE SLIDER - HOW to Access value to contrl a fan? on: February 08, 2012, 12:16:35 pm
 // From a browser use a horizontal Slider button to increase - or decrease speed of a fan using pwm  analog input A3/ output A4


           client.println(F("<hr >"));
           client.print(F("<form method=get name=N>")); //n for fan

           client.println("<input type='range' min='0' max='50' value='0' step='5' >");

           client.println(F("<input type=submit value=submit></form>"));
          
           client.println(F("<hr />"));

 1. If i use the code above with  a  browser (chrome) that supports html5 tags - i see the slider and can move it  -GOOD

 2. I cant seem to figure how to access the value of the input button and send it to an analog input        

 3.  which intern would control an analog output to speed up or slow down a Fan using pwm

Any help would be much appreciated

Joe


53  Using Arduino / Programming Questions / Re: Web Sever Will not respond When I add 1 line of Println code on: February 08, 2012, 08:14:40 am
Thanks,

I guess i was searching for to much criteria - memory worked fine

Joe
54  Using Arduino / Programming Questions / Re: Web Sever Will not respond When I add 1 line of Println code on: February 07, 2012, 06:52:50 pm
I recoded every line that i could using the :

client.println(F("<form  method=get name=LED>"));
--------------------------------------------------------------------------
Bingo!! - The server is now working well, quick and reliable responses.
---------------------------------------------------------------------------
I had been pointed in that direction before but I did not go far enough..

NOW:

I am able to add the input buttons as suggested and more..



I think the low memory was creeping in at various times and throwing me off.


Is there a method or a place to look to see what the arduino memory level is?

I have now learned the hard way that it can get you when you least expect it, so i would like to be able to keep an eye on it.

Thanks for taking the time  to help me along.

Arduino Forum sure is a great resource!!

Joe

Thanks
55  Using Arduino / Programming Questions / Re: Web Sever Will not respond When I add 1 line of Println code on: February 07, 2012, 11:12:14 am
PaulS,

Thanks for the pointers and code breakdown, it sure looks better, however If i try it , the buttons do not respond

I have been piecing a web server with code from various sketches and adding my own
I am learning day by day but need some experts to keep me on the right track

Its crude but works, minus some things i want to clean up

I would appreciate it If you or anyone interested would have a look at the complete code and suggest changes to make it better.

1. I would like the button layout you suggest to work but so far no go.
2. Any other change to clean it up would be also very much appreciated.

I plan on posting the code for all to use, once things are cleaned up ...


I have Attached the sketch
Thanks
Joe
56  Using Arduino / Programming Questions / Web Sever Will not respond When I add 1 line of Println code on: February 06, 2012, 10:59:33 pm
//controlling led via checkbox

          // this line will provides the radiobuttons that provide the input

          client.println("<form method=get name=LED> <input type='radio' name='L' value='1'>LED1 ON<br><input type='radio' name='L' value='0'>LED1 OFF<br><br><input type='radio' name='H' value='1'>SD9 VERT ANT ON<br><input type='radio' name='H' value='0'>G5RV ANT ON<br><br><input type='radio' name='A' value='1'>LED3 ON<br><input type='radio' name='A' value='0'>LED3 OFF<br><br><input type='radio' name='F' value='1'>PWR ON<br><input type='radio' name='F' value='0'>PWR OFF<br><br><input type=submit value=submit></form>");


          // button functions   --test area    TEST
         
          client.println("<form  method=get name=LED>");
          client.println("<button name=F value=1 type=submit style=height:25px;width:100px>PWR On</button>");
          client.println("<button name=F value=0 type=submit style=height:25px;width:100px>PWR Off</button>");
         
      //client.println("<button name=H value=1 type=submit style=height:25px;width:100px>SD9 ANT</button>"); // server will not respond
          client.println("</form><br />");
          client.println("<hr />");



PROBLEM:

1. The code above works as long as i do not  add the line indicated above.
2. If i delete one of the other button inputs and add the offending line it works?? Any idea what is the problem?
3. Also, i would like to break up the first set of form buttons into separate code lines but have not been able to get the correct syntax  tax

Thanks
running ide 1
Joe
57  Using Arduino / Programming Questions / Re: Cannot Change - ARDUINO HTML Color code To Display Correctly on: February 04, 2012, 10:41:22 pm
James C4S, Thanks for the quick reply


1. I recoded all colors with 'xxxxxx'   - Single quotes and removed the # - this seems to have stabilized the web server.

2. Your second pointer about saving ram...sounds like a good approach - i see the syntax but don't quite follow, could you provide an example for the code below?

client.println("<font color ='FFFF00' >The Room is now BRIGHT </font>");  //yellow


Joe
58  Using Arduino / Programming Questions / Cannot Change - ARDUINO HTML Color code To Display Correctly on: February 04, 2012, 09:49:13 pm
// HTML Code to print html web page
//Use photo cell to print html page WHEN The Room is Bright >> in yellow  or PRINT The Room is now Dark >> in red
//Sense detection works fine  but cannot seem to get the proper code to work to change the text to proper colors

          client.println("<font color=’red’><h1>INTERNET REMOTE CONTROL </font></h1>");//send first heading
          client.println("<hr />");
          client.println("<font color=’blue’ size=’5′>Analog input: "); //output some sample data to browser


          sensorValue = analogRead(sensorPin);
         
         // Print -  when room is dark in red or print light in yellow  when room has light
         
          if (sensorValue < 250) {
          client.println("<font color =#FF0000 >The Room is now DARK </font>"); //works
          }
          else {
          //client.println("<font size=’5′ font color =#FFFF00 >The Room is Bright </font>"); //THIS LINE DOES NOT WORK - hangs     my server

         client.println("The Room is Bright");  // HOWEVER THIS WORKS but no color change
          }
          client.println("<hr />");
          client.println("<br />");//some space between lines
         

Thanks for any help  -Joe
Pages: 1 2 3 [4]