Show Posts
Pages: 1 ... 9 10 [11] 12
151  Using Arduino / Programming Questions / Re: How i make delay .5 microseconds? on: January 24, 2012, 01:09:31 am
Finaly 95 KHz is wrong i think i want a bandwidth 30-56KHz ....possible frequencies....
152  Using Arduino / Programming Questions / Re: How i make delay .5 microseconds? on: January 24, 2012, 12:36:50 am
I want control my air condition United...i have another A/C Toyotomi i decode ok work to 38KHz i make a library...but the United i think no have the standard frequency 38KHz i decode the pulses but no work and i must test it with little different frequency 32,33,34....40,56 KHz....i have not osciloscope....
153  Using Arduino / Programming Questions / Re: How i make delay .5 microseconds? on: January 23, 2012, 07:06:08 am
How i use PWM for doing this?
154  Using Arduino / Programming Questions / Re: How i make delay .5 microseconds? on: January 23, 2012, 03:01:22 am
I want make IR pulse with accuracy 95KHz...i think i must use __asm__("nop\n\t"); .....
155  Using Arduino / Programming Questions / How i make delay .5 microseconds? on: January 23, 2012, 02:41:22 am
Hello i want make delay .5 microseconds(500 nanoseconds).I must use NOP() from assembly?I have ATmega328 16MHZ....nop for me is 62.5ns...ok i want 8 nop but i could use assebly code into my sketch?I must use library first?How i doing this?A small example please...
156  Using Arduino / General Electronics / Re: How i read low voltage digital signal from arduino with digital input ? on: January 22, 2012, 07:38:06 am
Thanks.I have BC 547 is ok?I make the similar circuit with Mosfet but no work....the Vgs(min)=2volt i think....The signal inverting with this circuit?
157  Using Arduino / General Electronics / How i read low voltage digital signal from arduino with digital input ? on: January 22, 2012, 07:00:11 am
Hello!I want read low voltage 1,8 volt signal (f=40KHz) with digital input pins.What hardware must connect with Arduino pin for amplifier the signal?Transistor?The arduino pin need 4-5 volt to understand high level "1".
158  Using Arduino / Programming Questions / Re: How i upload web page from sd card of ethernet shield w5100 for control leds? on: January 09, 2012, 09:15:01 am
I have many functions for control a/c (pulse Ir) and aruino flash memory 30k is not enough...could i use the sd card for upload code?
159  Using Arduino / Programming Questions / Re: How i upload web page from sd card of ethernet shield w5100 for control leds? on: January 09, 2012, 08:31:45 am
ok i make the code...but display the value at the buttom of page....
Code:
if (c == '\n' && currentLineIsBlank ) {
           delay(300);
           xClicksProcessed++;
           
           
           client.println("HTTP/1.1 200 OK");//8
            client.println("Content-Type: text/html");//9
            client.println();//10

             myFile = SD.open("index.htm");
  if (myFile) {
    Serial.println("index.htm:");
   
    // read from the file until there's nothing else in it:
    while (myFile.available()) {
    client.write(myFile.read());
    }
    // close the file:
    myFile.close();
  } else {
  // if the file didn't open, print an error:
    Serial.println("error opening index.htm");
  }

            client.print("<br>Analog input A3 (Temperature) reads: <b>");//Temperature sensor Lm35
            client.print(analogRead(3)*0.488);
            client.println("</b>");

            client.print("<p>Clicks since server booted: ");
            client.print(xClicksProcessed);
            client.println("</p>");
160  Using Arduino / Programming Questions / Re: How i upload web page from sd card of ethernet shield w5100 for control leds? on: January 09, 2012, 07:29:17 am
sorry .... client.print(analogRead(3)*0.488);
161  Using Arduino / Programming Questions / Re: How i upload web page from sd card of ethernet shield w5100 for control leds? on: January 09, 2012, 07:27:37 am
In my first simple code without sd card i use... client.print(analogsensor(3)) and work
i have connect Lm35 temperature sensor...
When i refresh page display new value...
162  Using Arduino / Programming Questions / Re: How i upload web page from sd card of ethernet shield w5100 for control leds? on: January 09, 2012, 07:02:28 am
Yes i want dynamic  web page...what javascript code i use for display web page the analog sensor value?
163  Using Arduino / Programming Questions / Re: How i upload web page from sd card of ethernet shield w5100 for control leds? on: January 08, 2012, 11:48:43 am
ok work web page ...i send data from sd card but no display my analog input...i use
Code:
while (myFile.available()) {
    client.write(myFile.read());
    }
    // close the file:
    myFile.close();
client.print display only mumbers...
164  Using Arduino / Programming Questions / Re: How i upload web page from sd card of ethernet shield w5100 for control leds? on: January 07, 2012, 09:43:18 am
I try this but no work...only display page...the led no work...file not found...

Code:
//This is the basic SDFat Webserver sketch, without any modifications
#include <SPI.h>
#include <SdFat.h>
#include <SdFatUtil.h>
#include <Ethernet.h>

byte mac[] = {
  0x90,0xA2,0xDA,0x00,0x26,0xEB};
byte ip[] = {
  192,168,1,15};
char rootFileName[] = "index.htm";  //root file name is what the homepage will be.
Server server(80);

const byte IR_PIN4=2;//Ir led pin

const byte LEDpin=3;//Indicator


Sd2Card card;  //SD Stuff
SdVolume volume;
SdFile root;
SdFile file;

#define error(s) error_P(PSTR(s))  //SD card errors stored in Program memory
void error_P(const char* str) {  //Error function
  PgmPrint("error: ");
  SerialPrintln_P(str);
  if (card.errorCode()) {
    PgmPrint("SD error: ");
    Serial.print(card.errorCode(), HEX);
    Serial.print(',');
    Serial.println(card.errorData(), HEX);
  }
  while(1);
}

void setup() {  //setup stuff
 
  pinMode(IR_PIN4,OUTPUT);
  digitalWrite(IR_PIN4,LOW);
  pinMode(LEDpin,OUTPUT);
  LEDOff();
 
  Serial.begin(9600);
  PgmPrint("Free RAM: ");
  Serial.println(FreeRam());
  pinMode(10, OUTPUT);
  digitalWrite(10, HIGH);
  if (!card.init(SPI_FULL_SPEED, 4)) error("card.init failed!");  //If you are having errors when reading from the SD card, change FULL to HALF
  if (!volume.init(&card)) error("vol.init failed!");
  PgmPrint("Volume is FAT");
  Serial.println(volume.fatType(),DEC);
  Serial.println();
  if (!root.openRoot(&volume)) error("openRoot failed");
  PgmPrintln("Files found in root:");
  root.ls(LS_DATE | LS_SIZE);
  Serial.println();
  PgmPrintln("Files found in all dirs:");
  root.ls(LS_R);
  Serial.println();
  PgmPrintln("Done");
  Ethernet.begin(mac, ip);
  server.begin();
}
#define BUFSIZ 100  //defines the buffer size.  100 gives plenty of room.  reduce size if more ram is needed.

void loop()
{
  char clientline[BUFSIZ];
  char *filename;
  int index = 0;
  int image = 0;
  Client client = server.available();
  if (client) {
    boolean current_line_is_blank = true;
    index = 0;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        if (c != '\n' && c != '\r') {
          clientline[index] = c;
          index++;
          if (index >= BUFSIZ)
            index = BUFSIZ -1;
          continue;
        }
        clientline[index] = 0;
        filename = 0;
        Serial.println(clientline);
        if (strstr(clientline, "GET / ") != 0) {  //If you are going to the homepage, the filename is set to the rootFileName
          filename = rootFileName;
        }
        if (strstr(clientline, "GET /") != 0) {
          if (!filename) filename = clientline + 5;  //gets rid of the GET / in the filename
          (strstr(clientline, " HTTP"))[0] = 0;  //gets rid of everything from HTTP to the end.
          Serial.println(filename);
          if (! file.open(&root, filename, O_READ)) {  //if the file doesn't exist a 404 is sent
            client.println("HTTP/1.1 404 Not Found");
            client.println("Content-Type: text/html");
            client.println();
            client.println("<h2>File Not Found!</h2>");
            break;
          }
          Serial.println("Opened!");
          client.println("HTTP/1.1 200 OK");
          if (strstr(filename, ".htm") != 0)  //Sets content type.
            client.println("Content-Type: text/html");
          else if (strstr(filename, ".css") != 0)
            client.println("Content-Type: text/css");
          else if (strstr(filename, ".png") != 0)
            client.println("Content-Type: image/png");
          else if (strstr(filename, ".jpg") != 0)
            client.println("Content-Type: image/jpeg");
          else if (strstr(filename, ".gif") != 0)
            client.println("Content-Type: image/gif");
          else if (strstr(filename, ".3gp") != 0)
            client.println("Content-Type: video/mpeg");
          else if (strstr(filename, ".pdf") != 0)
            client.println("Content-Type: application/pdf");
          else if (strstr(filename, ".js") != 0)
            client.println("Content-Type: application/x-javascript");
          else if (strstr(filename, ".xml") != 0)
            client.println("Content-Type: application/xml");
          else
            client.println("Content-Type: text");
          client.println();
         
          int16_t c;
          while ((c = file.read()) >= 0) {
              client.write((char)c);  //sends file to website client
          }
          file.close();
           
         
        }
        /*else {
          client.println("HTTP/1.1 404 Not Found");
          client.println("Content-Type: text/html");
          client.println();
          client.println("<h2>File Not Found!</h2>");
        }*/
        break;
      }
    if(strstr(clientline,"GET /?cmd=AC_ON")!=0) {  //look for the command to turn the led on
              LEDOn();  //turn the led on
              }
    else if(strstr(clientline,"GET /?cmd=AC_OFF")!=0) {  //look for command to turn led off. Note: If led is on, it will stay on until command is given to turn it off, even if multiple computers are on the site
              LEDOff();  //turn led off
              }
  }
   
    delay(1);
    client.stop();
  }
}

void LEDOn(){
digitalWrite(LEDpin,HIGH);
}

void LEDOff(){
digitalWrite(LEDpin,LOW);
}
165  Using Arduino / Programming Questions / How i upload web page from sd card of ethernet shield w5100 for control leds? on: January 07, 2012, 09:03:21 am
i want upload web page from sd card (ethernet w5100) for control leds...any idea for code with sd libraries?I doing without sd but no work for big web page...with many functions...

Code:
#include <SPI.h>
#include <Ethernet.h>


#define maxLength 40

String inString = String(maxLength);       // allocate a new String


const byte IR_PIN4=4;//Ir led pin

const byte LEDpin=8;//Indicator

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
byte ip[] = {192,168,1,15};
const byte Port = 80;

Server server(Port);

int counter=0;
char c;
word xClicksProcessed=0;
char codeOK='0';//start Code is blank....

void setup()
{
  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();

  Serial.begin(9600);//Restore, if you want to monitor program's
       //operation via serial monitor

 
  pinMode(IR_PIN4,OUTPUT);
  digitalWrite(IR_PIN4,LOW);
  pinMode(LEDpin,OUTPUT);
  LEDOff();
 
}

void loop()
{//1
  Client client = server.available();
    
     if (client) {//2
    boolean currentLineIsBlank = true;//3
    counter=0;
    inString="";//format inString
     while (client.connected()) {//4
      if (client.available()) {//45
         c = client.read();//6
        
          
         if ((c!='\n') && (c!='\r')){
         if (inString.length() < maxLength) {
              inString+=c;
         }        
         }
         // Serial.print(c);
         // Serial.print(inString);
         if (c == '\n' && currentLineIsBlank ) {
           delay(300);
           xClicksProcessed++;
          
          
           client.println("HTTP/1.1 200 OK");//8
            client.println("Content-Type: text/html");//9
            client.println();//10

            

            client.println("<html>");
            client.println("<head>");
            client.print("<title>Web Remote Control</title>");
            client.println("</head>");
            client.println("</head>");
            client.println();
            client.println("<body>");

            client.println("<center>");
            client.print("<h2>Web Remote Control A/C with Arduino and W5100 ver.22/12/2011");
          
            client.println("</h2>");

            

            client.println("<p>----");

            client.print("<br>Analog input A3 (Temperature) reads: <b>");//Temperature sensor Lm35
            client.print(analogRead(3)*0.488);
            client.println("</b>");
                  
              client.println("<form METHOD=get action=\"\">");
              client.println("<input type=password name=\"code\" size=\"4\" maxlength=\"4\">");
              client.println("<input type=submit name=\"Submit\" value=\"Code\">");
              client.println("</form>");
              client.println();
              
              
              client.println("<form METHOD=get action=\"\">");//to action isws na min xreiazete
              client.println("<input type=hidden name=\"cmd\" value=\"AC_ON\">");
              client.println("<input type=submit value=\"AC On\">");//Ac on
              client.println("</form>");
              client.println();

              client.println("<form METHOD=get action=\"\">");
              client.println("<input type=hidden name=\"cmd\" value=\"AC_OFF\">");
              client.println("<input type=submit value=\"AC Off\">");//Ac off
              client.println("</form>");
              client.println();
              
              client.println("<form METHOD=get action=\"\">");
              client.println("<select name=\"cmd\">");
              client.println("<option value=\"COOL\" selected=\"selected\" >Cool</option>");
              client.println("<option value=\"HEAT\">Heat</option>");
              client.println("<option value=\"DRY\">Dry</option>");      
              client.println("</select>");
              client.println(" ");
              client.println("<input type=\"submit\" name=\"Submit\" value=\"Mode\">");
              client.println("</form>");
              client.println();
            
              
              client.println("<form METHOD=get action=\"\">");
              client.println("<select name=\"cmd\">");
              client.println("<option value=\"temp30\" selected=\"selected\" >Temp 30</option>");
              //client.println("<option value=\"temp29\">Temp 29</option>");
              //client.println("<option value=\"temp28\">Temp 28</option>");
            
             // client.println("<option value=\"temp16\">Temp 16</option>");
              client.println("</select>");
              client.println(" ");
              client.println("<input type=\"submit\" name=\"Submit\" value=\"Temperature\">");
              client.println("</form>");
              client.println();
              
              client.println("<form METHOD=get action=\"\">");
              client.println("<select name=\"cmd\">");
              client.println("<option value=\"Fan_Low\" selected=\"selected\" >Fan low</option>");
              client.println("<option value=\"Fan_Medium\">Fan medium</option>");
              client.println("<option value=\"Fan_High\">Fan high</option>");      
              client.println("</select>");
              client.println(" ");
              client.println("<input type=\"submit\" name=\"Submit\" value=\"Fan speed\">");
              client.println("</form>");
              client.println();
            
    

              client.print("<p>Clicks since server booted: ");
              client.print(xClicksProcessed);
              client.println("</p>");

          client.println("<br>");

          
          client.println("<center>");


          break;//15
         }
        
         if (c == '\n') {//17
          currentLineIsBlank = true;//18
          
          Serial.print(inString);
          
          if (inString.startsWith("GET")>0) {//19
            
            if  (inString.startsWith("GET /?code=xxxx")>0) {//Set the code
                     codeOK='1';
                     Serial.println("codeOK=");
                     Serial.print(codeOK);
            }
            
            if ((codeOK=='1') && (counter <1)){counter++;
              if (inString.startsWith("GET /?cmd=AC_ON")>0 ){
                   LEDOn();
                   SendACCodeOn();
                  
                   //Serial.println("codeOK=");
                   //Serial.print(codeOK);
                   //Serial.print(inString);
                  
              }
              if (inString.startsWith("GET /?cmd=AC_OFF")>0){
                   LEDOff();
                   SendACCodeOff();
              }
              
              if (inString.startsWith("cmd=COOL",6)>0){
              
                 SendACCode_modeCool();    
                  
              }
              if (inString.startsWith("cmd=HEAT",6)>0){
                  
                 SendACCode_modeHeat();
              }
              if (inString.startsWith("cmd=DRY",6)>0){
                  
                 SendACCode_modeDry();
              }
               if (inString.startsWith("cmd=Fan_Low",6)>0){
                  
                 SendACCode_modeFanspeedLow();
              }
              if (inString.startsWith("cmd=Fan_Medium",6)>0){
                  
                 SendACCode_modeFanspeedMedium();
              }
              if (inString.startsWith("cmd=Fan_High",6)>0){
                  
                 SendACCode_modeFanspeedHigh();
              }
              if (inString.startsWith("cmd=temp30",6)>0){
                  
                 SendACCode_Temp_30();
              }
              
              
              //if (inString.indexOf("cmd=temp25")>0){
                  
                 //SendACCode_Temp_25();
             // }
              //if (inString.indexOf("cmd=temp24")>0){
                  
                 //SendACCode_Temp_24();
             // }
              if (inString.startsWith("cmd=temp23",6)>0){
                  
                 SendACCode_Temp_23();
              }
            
              if (inString.indexOf("cmd=temp16")>0){
                  
                 //SendACCode_Temp_16();
              } */
              
            }//codeok
          }//get
         }//current line
                    
               else if (c != '\r') {        //20
          currentLineIsBlank = false;//21
               }
         }//client avalaible
      }
      delay(1);//25
    client.stop();//26
  }//27

}//28

void LEDOn(){
digitalWrite(LEDpin,HIGH);
}

void LEDOff(){
digitalWrite(LEDpin,LOW);
}




Pages: 1 ... 9 10 [11] 12