Show Posts
Pages: [1] 2
1  International / Portugues / Nao consigo estabelecer ligacao entre siemens e arduino on: August 11, 2012, 05:45:51 pm
Viva tenho um siemens que tou a tentar conectar junto com o arduino para receber e enviar comandos at.

O que e certo e que nao tou a conseguir com que os dois se liguem um ao outro.

Tou a usar este esquema que esta aqui:

https://sites.google.com/site/carlosoliveiraprojects/home/arduino/gsm-and-arduino

mas inves dessas resistencias la linha lilás estou a usar uma de 12k e 18k mas mesmo assim sem sucesso.

alguem me pode ajudar neste sentido????

o codigo que estou a usar para ver se esta a funcionar é este:

Code:
/*
HARDWARE SETUP
13 -Led pin Debug 13 (used for status)
2 -RX (phone) 2
3 -TX (phone) 3
*/

#include <SoftwareSerial.h>
#define rxPin 2
#define txPin 3

#define ledPin 13 //Used for DEBUG

SoftwareSerial phone = SoftwareSerial(rxPin, txPin);

void setup() 
{
  pinMode(ledPin,OUTPUT); // LED DEBUG
  //Serial -------------------------------------------------
  // Open serial communications and wait for port to open:
  Serial.begin(9600);  // DEBUG
  while (!Serial) {;
  // wait for serial port to connect.Needed for Leonardo only
  }
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  phone.begin(9600);
}

void loop() // run over and over
{
  if (phone.available()) Serial.write(phone.read());
  if (Serial.available()) phone.write(Serial.read());
}

ou seja quando escrevo no serial monitor AT
NAO me retorna nada.
2  Topics / Home Automation and Networked Objects / Re: Control Arduino via SMS without SHIELD GSM on: August 09, 2012, 05:12:11 pm
John, i found this sites:

http://webgsmremotecontrol.webs.com/arduinogsmcode.htm
http://www.dreamfabric.com/sms/


I want to do is:

Send a message on my phone to my siemens connected to the Arduino:

sms: turn pin13
Arduino then connects the pin 13 high
and
Arduino then sends an sms to me: PIN 13 IS ON
3  Topics / Home Automation and Networked Objects / Control Arduino via SMS without SHIELD GSM on: August 09, 2012, 04:13:01 pm
Hello ppl.

I found this site:

https://sites.google.com/site/carlosoliveiraprojects/home/arduino/gsm-and-arduino

this guy can make the arduino send an sms to the mobile phone number as you can see on the site.

I wonder if you can do the opposite, I want to send a message from my phone to the arduino to trigger a relay.

Is it possible? somebody help me with the code?
4  International / Portugues / Re: Ajuda no Codigo Activar Sensor PIR entre uma certa hora 21:00 /00:00 on: August 08, 2012, 03:23:17 pm
Eu tenho o rtc time.

Vou mostrar ja o que ta feito.

Code:
/*
 * HeroAlarm
 *
 *
 */

#include <Time.h> 
#include <Wire.h> 
#include <DS1307RTC.h>
#include <TimeAlarms.h>

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

int calibrationTime = 0;       
long unsigned int lowIn;         
long unsigned int pause = 0; 
boolean lockLow = true;
boolean takeLowTime; 

int pirPin = 8;    //SINAL DO PIR
int ledPin = 12; // LUZ DO SENSOR PIR RELE NUMERO 2
////////////////


int relePin  = 13; // RELE connected to digital pin 2
int radioPin = 03; // RADIO connected to digital pin 3
//int releDiaEspecificoPin = 02; // RELE connected to digital pin 4
int numero;


#define RELE1 11 // ROUTER RELE NUMERO 1
#define RELE2 22
#define RELE3 20
#define RELE4 21

//int pirpin = HIGH;
//int ledpin = LOW;
int RELE1_STATE = HIGH;
int RELE2_STATE = LOW;
int RELE3_STATE = LOW;
int RELE4_STATE = LOW;




//=======================================================
// ENTRADAS DTMF DIGITAIS
//=======================================================
int pinBit01 = 7; // azul
int pinBit02 = 6; // branco
int pinBit03 = 5; // amarelo
int pinBit04 = 4; // verde
int pinBitSts= 3; // laranja


int bit01 = 0;   
int bit02 = 0;   
int bit03 = 0;   
int bit04 = 0; 
int bitSts= 0; 




boolean proceed = false; //Fag que habilita o funcionamento dos comandos mediante senha digitada corretamente - inicializa falso!


String tmpPass =' '; //Armazenamento da senha digitada no telemóvel!


String password = "1234"; // Defina sua senha aqui - pode ser de quaisquer número de dígitos!




void setup()  {
  Serial.begin(9600);
 // pinMode(relePin, OUTPUT);
 // digitalWrite(relePin, LOW);
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, HIGH);
  digitalWrite(pirPin, HIGH);
  pinMode(pirPin, INPUT);
 
  //digitalWrite(pirPin, LOW);
  pinMode(RELE1, OUTPUT); // ROUTER
 // pinMode(RELE2, OUTPUT); 
  //pinMode(RELE3, OUTPUT); 
  //pinMode(RELE4, OUTPUT); 
 
  digitalWrite(RELE1, HIGH); //ROUTER
  //digitalWrite(RELE2, LOW); 
  //digitalWrite(RELE3, LOW); 
  //digitalWrite(RELE4, LOW); 
 


  Serial.println("Aguardando comando...");



  setSyncProvider(RTC.get);   // the function to get the time from the RTC
  if(timeStatus()!= timeSet)
  Serial.println("Unable to sync with the RTC");
  else
  Serial.println("RTC has set the system time");       
     
  //Alarm.alarmRepeat(dowSaturday,00,57,30, ligarReleSegundaFeira);  // Ligar todas as segundas feiras as 20:00:00 um rele
 // Alarm.alarmRepeat(dowSaturday,00,58,00, desligarReleSegundaFeira);  // Desligar á segunda feira também as 23:50:00.

  //Alarm.alarmRepeat(8,00,0, ligarRadio);  // Ligar todos os dias as 08:00:00 um radio
  //Alarm.alarmRepeat(18,00,14, desligarRadio);  //  e desligar as 18:00:14
 

 
  }



void loop(){
  digitalClockDisplay();
  //Alarm.delay(0); // wait one sec
 
bitSts= digitalRead(pinBitSts);
bit01 = digitalRead(pinBit01);   
bit02 = digitalRead(pinBit02);   
bit03 = digitalRead(pinBit03);   
bit04 = digitalRead(pinBit04);   


numero   = (bit01 * 1) + (bit02 * 2) + (bit03 * 4) + (bit04 * 8);


if (bitSts == HIGH && numero < 13) { 
 
Serial.print("Recebido: ");   
switch (numero){
      case 1:
        Serial.println("1");
        tmpPass += '1'; //Adiciona o número digitado em tmpPass
       
        /* COMANDO PARA RELE1 */
        if (proceed == true) // Se proceed é verdadeiro (a senha foi digitada corretamente) comando é executado!
        {
          RELE1_STATE = !RELE1_STATE; // Troca de estado (HIGH/LOW) cada vez que pressionar o botão.
          digitalWrite(RELE1, RELE1_STATE); //Liga-desliga Relé.
        }       
        break;
       
      case 2:
        Serial.println("2");
        tmpPass += '2'; //Adiciona o número digitado em tmpPass
       
        /* COMANDO PARA RELE2 */
        if (proceed == true) // Se proceed é verdadeiro (a senha foi digitada corretamente) comando é executado!
        {
          RELE2_STATE = !RELE2_STATE; // Troca de estado (HIGH/LOW) cada vez que pressionar o botão.
          digitalWrite(RELE2, RELE2_STATE); //Liga-desliga Relé.
        }
        break;
       
      case 3:
        Serial.println("3");
        tmpPass += '3'; //Adiciona o número digitado em tmpPass
       
        /* COMANDO PARA RELE3 */
        if (proceed == true) // Se proceed é verdadeiro (a senha foi digitada corretamente) comando é executado!
        {
          RELE3_STATE = !RELE3_STATE; // Troca de estado (HIGH/LOW) cada vez que pressionar o botão.
          digitalWrite(RELE3, RELE3_STATE); //Liga-desliga Relé.
        }
       
        break;
       
      case 4:
        Serial.println("4");
        tmpPass += '4'; //Adiciona o número digitado em tmpPass
       
        /* COMANDO PARA RELE4 */
        if (proceed == true) // Se proceed é verdadeiro (a senha foi digitada corretamente) comando é executado!
        {
          RELE4_STATE = !RELE4_STATE; // Troca de estado (HIGH/LOW) cada vez que pressionar o botão.
          digitalWrite(RELE4, RELE4_STATE); //Liga-desliga Relé.
        }
       
        break;
       
      case 5:
        Serial.println("5");
        tmpPass += '5'; //Adiciona o número digitado em tmpPass
        break;
       
      case 6:
        Serial.println("6");
        tmpPass += '6'; //Adiciona o número digitado em tmpPass
        break;
       
      case 7:
        Serial.println("7");
        tmpPass += '7'; //Adiciona o número digitado em tmpPass
        break;
       
      case 8:
        Serial.println("8");
        tmpPass += '8'; //Adiciona o número digitado em tmpPass
        break;
       
      case 9:
        Serial.println("9");
        tmpPass += '9'; //Adiciona o número digitado em tmpPass
        break;
       
      case 10:
        Serial.println("0");
        tmpPass += '0'; //Adiciona o número digitado em tmpPass
        break;
       
      case 11: // Caractere '*'
        Serial.println("*");
        tmpPass =' '; //Limpa para armazenar a senha novamente!
        proceed = false; //Desabilita todos os comandos até que a senha seja digitada novamente!
        break;
       
      case 12: // Caractere '#'
        Serial.println("#");
       
        tmpPass = tmpPass.trim();//Retira os espaços em branco - ver caractere '*'!
   
        if (tmpPass == password) { // Se a senha digitada for igual a senha armazenada...
          Serial.println("Senha correta!");
          proceed = true; //Habilita todos os comandos via telemóvel
        }else{
          Serial.println("Senha ERRADA!");
          proceed = false; //Desabilita todos os comandos via telemóvel
        }
       
        /*
        //Caso queira ver a saida da senha é só descomentar
        Serial.print("tmpPass= ");
        Serial.println(tmpPass);
        Serial.print("password= ");
        Serial.println(password);
        */
       
        break;   
  }


 
 
 // Zeram todas as variáveis
  numero = 0;
  bit01 = 0;   
  bit02 = 0;   
  bit03 = 0;   
  bit04 = 0;   
  bitSts= 0; 
  delay (500);
  }




 

    if(digitalRead(pirPin) == LOW){
      digitalWrite(ledPin, HIGH);   //the led visualizes the sensors output pin state
       if(lockLow){ 
         lockLow = false;           
         
         delay(50);
         }         
         takeLowTime = true;
       }

     if(digitalRead(pirPin) == HIGH){       
      digitalWrite(ledPin, LOW);  //the led visualizes the sensors output pin state

       if(takeLowTime){
        lowIn = millis();          //save the time of the transition from high to LOW
        takeLowTime = false;       //make sure this is only done at the start of a LOW phase
        }
     
       if(!lockLow && millis() - lowIn > pause){ 
           //makes sure this block of code is only executed again after
           //a new motion sequence has been detected
           lockLow = true;                       
          delay(50);
           }
       }
 



}
////////////////////////////////////////////////////////



 









void ligarReleSegundaFeira() {
  digitalWrite(relePin, HIGH); // Ligar um rele



void desligarReleSegundaFeira() {
  digitalWrite(relePin, LOW); // Desligar um rele



void ligarRadio() {
  digitalWrite(radioPin, HIGH); // Ligar um Radio



void desligarRadio() {
  digitalWrite(radioPin, LOW); // Desligar um Radi






void digitalClockDisplay(){
  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.print(" ");
  Serial.print(day());
  Serial.print(" ");
  Serial.print(month());
  Serial.print(" ");
  Serial.print(year());
 Serial.println();
}

void printDigits(int digits){
   //utility function for digital clock display: prints preceding colon and leading 0
Serial.print(":");
  if(digits < 10)
    Serial.print('0');
  Serial.print(digits);

}


5  International / Portugues / Ajuda no Codigo Activar Sensor PIR entre uma certa hora 21:00 /00:00 on: August 07, 2012, 04:05:02 pm
Viva eu tenho o seguinte codigo todo a funcionar:


O que pretendo , coisas que nao consigo fazer e peço ajuda é:

Eu pretendia que esse sensor pir que está no codigo, apenas se activasse entre as 21:00 até as 00:00.
Atraves do que esta feito alguem pode alterar o projecto e colocar online?

Obrigado
6  Topics / Home Automation and Networked Objects / Re: Ethernet Shield with index.htm SDcard. on: April 15, 2012, 11:17:25 am
hummmm this is something very difficult for me.

Do all you can send me the sketch already modified?
Or is abusing your generosity?

I do not know programming, these codes have been taking and adapting.

Thanks again
7  Topics / Home Automation and Networked Objects / Re: Ethernet Shield with index.htm SDcard. on: April 15, 2012, 10:53:15 am
You don't have to answer. If you manage to get by the hardware problem, then I would suspect this comparison:
Code:
       if(readString.trim() == ("GET /?C=1678 HTTP/1.1")){
          //client.println("<h1>Clave Ok</h1>");
          Portada();
       }else{
          //client.println("<h1>Clave Erronea</h1>");
       }    

Just talking out loud here. I would try this instead. But that is just me.
Code:
       if(strcmp(readString.trim(), "GET /?C=1678 HTTP/1.1") == 0) {
          //client.println("<h1>Clave Ok</h1>");
          Portada();
       }else{
          //client.println("<h1>Clave Erronea</h1>");
       }    




i try this but gives errores


Code:
if(strcmp(readString.trim(), "GET /?C=1678 HTTP/1.1") == 0) {
          //client.println("<h1>Clave Ok</h1>");
          Portada();
       }else{
          //client.println("<h1>Clave Erronea</h1>");
       }    

look:

http://www.freeimagehosting.net/qap5b
8  Topics / Home Automation and Networked Objects / Re: Ethernet Shield with index.htm SDcard. on: April 15, 2012, 09:52:53 am
Thank you for your attention but I will not answer anymore, because did not understand my last post, and use the google translator did not help.

Forget the part of the SD, just want to know why when I type ip: 6969 on another computer it does not appear to me that:

http://imageshack.us/photo/my-images/525/controlcz.jpg/
http://imageshack.us/photo/my-images/525/controlcz.jpg/


but this:

http://imageshack.us/photo/my-images/29/principals.jpg/


I'm not mad at you, I'm just frustrated because he could not make them understand
9  Topics / Home Automation and Networked Objects / Re: Ethernet Shield with index.htm SDcard. on: April 15, 2012, 09:35:53 am
Sorry, but I think you do not understand what I said.

The code is all working beautifully.

The only thing that is happening is wrong:

When I type my ip: 6969 in browser it asks for the password:


http://imageshack.us/photo/my-images/525/controlcz.jpg/


after entering the correct password it will connect the main page:
http://imageshack.us/photo/my-images/29/principals.jpg/


  

Now what is wrong is if I close the browser, or attempt to access another computer to my ip: 6969 does not show new password to page:

http://imageshack.us/photo/my-images/525/controlcz.jpg/



but goes direct on the main page
http://imageshack.us/photo/my-images/29/principals.jpg/


  
Do you understand now? I want whenever you go to ip: 6969 it enters the password page.
10  Topics / Home Automation and Networked Objects / Re: Ethernet Shield with index.htm SDcard. on: April 15, 2012, 08:49:22 am
sorry the code is:

Code:
#include <Ethernet.h>
#include <SPI.h>
/*
    Simple Ethernet Test

 Arduino server outputs simple text to browser

     The circuit:
     * Arduino Duemilanove
 * Arduino Ethernet shield
 * Basic FTDI breakout 5V
 *LED connected to GND and digital pin 4 via resistor

 By Minde
     http://www.sciencprog.com/
 */

byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x49, 0xD6 };
byte ip[]    = {192,168,1,70}; // IP address of WiShield
byte gateway[]  = {192,168,1,254}; // router or gateway IP address
byte subnet[] = {255,255,255,0};


Server server(6969);        //server port
int ledPin = 4;  // LED pin
int LEDpin = 7;
String state = String(3);
word Adc = 0;
String readString = String(30); //string for fetching data from address
boolean LEDON = false; //LED status flag



void Pasword();
void Portada();


void setup(){
  //start Ethernet
  Ethernet.begin(mac, ip, gateway, subnet);
  //Set pin 4 to output
  pinMode(LEDpin,OUTPUT);
 
  digitalWrite(LEDpin,LOW);
  state = "OFF";
String state = String(3);
  //enable serial datada print
  Serial.begin(9600);
}


void loop(){
  // Create a client connection
 
  Client client = server.available();
  if (client) {
    while (client.connected()){   
      char c = client.read();
      if (readString.length() < 30){
         readString += c;
      }
      Serial.print(c);
      if (c == '\n') {     
        if(readString.trim() == ("GET /?C=1678 HTTP/1.1")){
          //client.println("<h1>Clave Ok</h1>");
          Portada();
       }else{
          //client.println("<h1>Clave Erronea</h1>");
       }     
   
   
       //client.println("HTTP/1.1 200 OK");
       //client.println("Content-Type: text/html");
       client.println();
       client.print("<body style=background-color:#ffffff>");     

       client.println("<h1>Control de Acceso</h1>");       
       client.println("<form method=get name=LED>");
       client.println("<input type=""password"" name=C>");
     
     
       client.println("<input type=submit value=submit></form>");
     

       //clearing string for next read
       readString="";
       //stopping client
       client.stop();     
    }
  }
}
}



void Portada(){
while(1){
  // Create a client connection
  Client client = server.available();
 if (client) {
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply

        if (readString.length() < 30) {
          readString.concat(c);
        }

        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          int LED = readString.indexOf("LED=");

          if (readString.substring(LED,LED+5) == "LED=T") {
            digitalWrite(LEDpin,HIGH);
            state = "ON";
          }
          else if (readString.substring(LED,LED+5) == "LED=F") {
            digitalWrite(LEDpin,LOW);
            state = "OFF";
          }
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          client.println("<form  method=get name=form>");
         
          client.println("<img src='http://dl.dropbox.com/u/6916111/tvoff.png' style=\"position:fixed;left:68px;top:80px;width:636px;height:431px;z-index:1;padding:0;\">");
          if (state == "ON") { 
       //   client.print("TESTE ");       
          client.println("<img src='http://dl.dropbox.com/u/6916111/tvon.png' type='image' style=\"position:fixed;left:254px;top:146px;width:146px;height:93px;z-index:2;padding:0;\">");
          client.println("<a href=\"./?LED=F\" src='http://dl.dropbox.com/u/6916111/off.png' type='image' style=\"position:fixed;left:254px;top:146px;width:146px;height:93px;z-index:2;padding:0;\">");
}

else {
client.println("<img src='http://dl.dropbox.com/u/6916111/off.png' type='image' style=\"position:fixed;left:254px;top:146px;width:146px;height:93px;z-index:2;padding:0;\">");
          client.println("<a href=\"./?LED=T\" src='http://dl.dropbox.com/u/6916111/tvon.png' type='image' style=\"position:fixed;left:254px;top:146px;width:146px;height:93px;z-index:2;padding:0;\">");
}

          //client.print("LED is ");
         // client.print(state);
          client.print("<br><br>");

         
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    readString = "";
    // close the connection:
    client.stop();
     }
      }
}
void Pasword();





11  Topics / Home Automation and Networked Objects / Re: Ethernet Shield with index.htm SDcard. on: April 14, 2012, 06:42:10 pm
Viva, I managed to solve my problem.
Now only one point missing out ... I can not give and ask for help solving.
 
The code that is working and this:
 
Code: [Select]
# Include <Ethernet.h>
# Include <SPI.h>
/ *
    Simple Ethernet Test
 
 Arduino server outputs simple text to browser
 
     The circuit:
     * Arduino Duemilanove
 * Arduino Ethernet shield
 * Basic FTDI 5V breakout
 * LED connected to digital pin 4 and GND via resistor
 
Code:
* /
 
Byte mac [] = {0x90, 0xA2, 0xDA, 0x00, 0x49, 0xD6};
IP Byte [] = {} 192,168,1,70 / / IP address of WiShield
Gateway Byte [] = {} 192,168,1,254 / / router or gateway IP address
Subnet Byte [] = {} 255,255,255,0;
 

Server server (6969) / / server port
LedPin Int = 4 / / LED pin
Int ledPin = 7;
String state = String (3);
Word Adc = 0;
ReadString String = String (30) / / string for fetching data from address
LEDON Boolean = false; / / LED status flag
 
 
 
Void Pasword ();
Carried Void ();
 

Void setup () {
  / / Start Ethernet
  Ethernet.begin (mac, IP, gateway, subnet);
  / / Set to output pin 4
  PinMode (ledPin, OUTPUT);
 
  DigitalWrite (ledPin, LOW);
  State = "OFF";
String state = String (3);
  / / Enable serial print dated
  Serial.begin (9600);
}
 

Void loop () {
  / / Create a client connection
 
  Client client = server.available ();
  If (client) {
    While (client.connected ()) {
      Char client.read c = ();
      If (readString.length () <30) {
         ReadString + = c;
      }
      Serial.print (c);
      If (c == '\ n') {
        if (readString.trim () == ("GET /? C = 1678 HTTP/1.1")) {
          / / Client.println ("Clave <h1> Ok </ h1>");
          Carried ();
       Else {}
          / / Client.println ("erroneous <h1> Clave </ h1>");
       }
   
   
       / / Client.println ("HTTP/1.1 200 OK");
       / / Client.println ("Content-Type: text / html");
       Client.println ();
       Client.print ("<body style=background-color:#ffffff>");
 
       Client.println ("Control de Acceso <h1> </ h1>");
       Client.println ("<form method=get name=LED>");
       Client.println ("<input type=""password"" name=C>");
     
     
       Client.println ("<input type=submit value=submit> </ form>");
     
 
       / / Read next string is clearing
       ReadString = "";
       / / Stopping client
       Client.stop ();
    }
  }
}
}
 
 
 
Void Homepage () {
While (1) {
  / / Create a client connection
  Client client = server.available ();
 If (client) {
    / / An http request ends with a blank line
    CurrentLineIsBlank Boolean = true;
    While (client.connected ()) {
      If (client.available ()) {
        Char client.read c = ();
        / / If you've gotten to the end of the line (received a newline
        / / Character) and the line is blank, the http request has ended,
        / / So Can you send a reply
 
        If (readString.length () <30) {
          ReadString.concat (c);
        }
 
        If (c == '\ n' && currentLineIsBlank) {
          / / Send a standard http response header
          LED Int readString.indexOf = ("LED =");
 
          If (readString.substring (LED, +5) == '= LED T ") {
            DigitalWrite (ledPin, HIGH);
            State = "ON";
          }
          Else if (readString.substring (LED, +5) == "LED = F") {
            DigitalWrite (ledPin, LOW);
            State = "OFF";
          }
          Client.println ("HTTP/1.1 200 OK");
          Client.println ("Content-Type: text / html");
          Client.println ();
          Client.println ("<form method=get name=form>");
         
          Client.println ("<img src = 'http://dl.dropbox.com/u/6916111/tvoff.png' style = \" position: fixed; left: 68px; top: 80px; width: 636px; height: 431px; z-index: 1; padding: 0; \ ">");
          If (state == "ON") {
       / / Client.print ("TEST");
          Client.println ("<img src = 'http://dl.dropbox.com/u/6916111/tvon.png' type =" image "style = \" position: fixed; left: 254px; top: 146px; width : 146px; height: 93px; z-index: 2; padding: 0; \ ">");
          Client.println ("<a href = \". /? LED = F \ "src = 'http://dl.dropbox.com/u/6916111/off.png' type =" image "style = \" position : fixed; left: 254px; top: 146px; width: 146px; height: 93px; z-index: 2; padding: 0; \ ">");
   }
   
  else {
  client.println ("<img src = 'http://dl.dropbox.com/u/6916111/off.png' type =" image "style = \" position: fixed; left: 254px; top: 146px; width : 146px; height: 93px; z-index: 2; padding: 0; \ ">");
          client.println ("<a href = \". /? LED T = \ "src = 'http://dl.dropbox.com/u/6916111/tvon.png' type =" image "style = \" position : fixed; left: 254px; top: 146px; width: 146px; height: 93px; z-index: 2; padding: 0; \ ">");
   }
 
          / / Client.print ("LED is");
         / / Client.print (state);
          client.print ("<br>");
 
         
          break;
        }
        if (c == '\ n') {
          / / You're starting a new line
          currentLineIsBlank = true;
        }
        else if (c! = '\ r') {
          / / You've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    / / Give the web browser time to receive the data
    delay (1);
    ReadString = "";
    / / Close the connection:
    client.stop ();
     }
      }
}


 
 
 
 
 
 
 
 
 
what is happening is this:
how do I access my shield through the browser
it goes OK, and do what you have to do is:
 
Show a field where you put the password and then do a submit button and proceed to the main page.
 
Ate there all right.
 
What is bad is if I close the browser and return the ip of my shield in the browser, it does not already asking for the password but goes directly to the main page and I do not want it.
 
 
 
Thank you
12  Topics / Home Automation and Networked Objects / Re: Ethernet Shield with index.htm SDcard. on: April 10, 2012, 10:44:18 am
What I want is simple, but you are not understanding.

I have this code, this code is doing is opening an index.html that is stored on the SD ethernet shield.

Code:
<html>
<body>

<img src="w3schools.jpg" width="104" height="142" />

</body>
</html>


now, i want when click on w3schools.jpg...that turn led on pin3
and when click again turn led on pin3.


this is code i want tranform:

#include <LiquidCrystal.h>
#include <SPI.h>
#include <SdFat.h>
#include <SdFatUtil.h>
#include <Ethernet.h>
#define BUFSIZ 128
#define greenLEDandBEEP 2
#define redLEDpin 3
boolean led2 = true;
int hits = 0; // Set the number of hits the hit counter will start at.
int units = 0;
int count = 0;
int photocellPin = 2;
int photocellReading;
LiquidCrystal lcd(4, 5, 6, 7, 8, 9);

//Local ethernet setup
byte mac[] = {
  0x90, 0xA2, 0xDA, 0x00, 0x1C, 0x0E };
byte ip[] = {
  192, 168, 1, 80 };
char rootFileName[] = "index.htm";
Server server(8080);

//SD card stuff
Sd2Card card;
SdVolume volume;
SdFile root;
SdFile file;
#define error(s) error_P(PSTR(s))
void error_P(const char* str) {
  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() {
  lcd.begin(16, 2);
  lcd.print("Web Server v2.00");
  lcd.setCursor(0, 1);
  lcd.print("Hits:");

  Serial.begin(9600);

  pinMode(greenLEDandBEEP, OUTPUT);
  pinMode(redLEDpin, OUTPUT);

  PgmPrint("Free RAM: ");
  Serial.println(FreeRam()); 

  pinMode(10, OUTPUT);             
  digitalWrite(10, HIGH);             

  if (!card.init(SPI_HALF_SPEED, 4)) error("card.init failed!");

  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();
}


void loop()
{
  if(count >=500)
  { 
    led2 = !led2;
    digitalWrite(redLEDpin, led2);
    count = 0;
  }
  count +=1;

  char clientline[BUFSIZ];
  char *filename;
  int image = 0;
  int index = 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) {
          filename = rootFileName;

        }
        if (strstr(clientline, "GET /") != 0) {
          if (!filename) filename = clientline + 5;

          (strstr(clientline, " HTTP"))[0] = 0;

          Serial.println(filename);

          if (! file.open(&root, filename, O_READ)) {
            client.println("HTTP/1.1 404 Not Found");
            client.println("Content-Type: text/html");
            client.println();
            client.println("<h2>Error 404</h2>");
            client.println("<s2>The file does not exist.<s2>");
            client.println("");
            break;
          }

          Serial.println("Opened!");
          //File types
          client.println("HTTP/1.1 200 OK");
          if (strstr(filename, ".htm") != 0)
            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) {
            //Serial.print((char)c); //Prints all HTML code to serial (For debuging)
            client.print((char)c); //Prints all HTML code for web page
          }

          //Hit counter math
          if(units >= 2)
          {
            hits ++;
            units = 0;
          }
          units +=1;
          //End hit counter math

          //Print the hit counters and light value
          lcd.setCursor(6, 1);
          lcd.print(hits); //Print hits for LCD hit counter

          client.print("<html><body>"); //HTML code starts here
          client.print("<P align=\"center\">");
          client.print("Hits since reset: <b>");   
          client.print(hits); //Print hits to client
          client.print("</b><br>");

          photocellReading = analogRead(photocellPin);
          client.print("Light reading: ");
          client.print(photocellReading); //Prints light reading to client

          // A few threshholds
          if (photocellReading < 10) {
            client.print(" - Dark");
          }
          else if (photocellReading < 200) {
            client.print(" - Dim");
          }
          else if (photocellReading < 500) {
            client.print(" - Light");
          }
          else if (photocellReading < 800) {
            client.print(" - Bright");
          }
          else {
            client.print(" - Very bright");
          }

          client.print("</p></body></html>"); //HTML code ends here
          //End hit counter and light value

          file.close();

        }
        else {
          client.println("HTTP/1.1 404 Not Found");
          client.println("Content-Type: text/html");
          client.println();
          client.println("<h2>Error 404</h2>");
          client.println("");
        }
        break;
      }
    }
    digitalWrite(greenLEDandBEEP, HIGH);
    delay(1);
    digitalWrite(greenLEDandBEEP, LOW);
    client.stop();
  }

}


Now I do not know what the code I have to add to this that when I click on the image of my index.hml to connect the pin digitalWrite 7 and when you click the image again to connect the low digitalWrite pin7.

I do not want you Go take me examples of sites and links.

I want you to modify that code and send it to me, because I do not understand any of this.

thanks friends.
13  Topics / Home Automation and Networked Objects / Re: Ethernet Shield with index.htm SDcard. on: April 08, 2012, 03:16:14 pm
zoom thanks for reply, and your attention.

But i dont understand how can transform this code to be working whith my index.html

see.. my index.html code:

<html>
<body>

<img src="w3schools.jpg" width="104" height="142" />

</body>
</html>


now, i want when click on w3schools.jpg...that turn led on pin3
and when click again turn led on pin3.


this is code i want tranform:

#include <LiquidCrystal.h>
#include <SPI.h>
#include <SdFat.h>
#include <SdFatUtil.h>
#include <Ethernet.h>
#define BUFSIZ 128
#define greenLEDandBEEP 2
#define redLEDpin 3
boolean led2 = true;
int hits = 0; // Set the number of hits the hit counter will start at.
int units = 0;
int count = 0;
int photocellPin = 2;
int photocellReading;
LiquidCrystal lcd(4, 5, 6, 7, 8, 9);

//Local ethernet setup
byte mac[] = {
  0x90, 0xA2, 0xDA, 0x00, 0x1C, 0x0E };
byte ip[] = {
  192, 168, 1, 80 };
char rootFileName[] = "index.htm";
Server server(8080);

//SD card stuff
Sd2Card card;
SdVolume volume;
SdFile root;
SdFile file;
#define error(s) error_P(PSTR(s))
void error_P(const char* str) {
  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() {
  lcd.begin(16, 2);
  lcd.print("Web Server v2.00");
  lcd.setCursor(0, 1);
  lcd.print("Hits:");

  Serial.begin(9600);

  pinMode(greenLEDandBEEP, OUTPUT);
  pinMode(redLEDpin, OUTPUT);

  PgmPrint("Free RAM: ");
  Serial.println(FreeRam()); 

  pinMode(10, OUTPUT);             
  digitalWrite(10, HIGH);             

  if (!card.init(SPI_HALF_SPEED, 4)) error("card.init failed!");

  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();
}


void loop()
{
  if(count >=500)
  { 
    led2 = !led2;
    digitalWrite(redLEDpin, led2);
    count = 0;
  }
  count +=1;

  char clientline[BUFSIZ];
  char *filename;
  int image = 0;
  int index = 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) {
          filename = rootFileName;

        }
        if (strstr(clientline, "GET /") != 0) {
          if (!filename) filename = clientline + 5;

          (strstr(clientline, " HTTP"))[0] = 0;

          Serial.println(filename);

          if (! file.open(&root, filename, O_READ)) {
            client.println("HTTP/1.1 404 Not Found");
            client.println("Content-Type: text/html");
            client.println();
            client.println("<h2>Error 404</h2>");
            client.println("<s2>The file does not exist.<s2>");
            client.println("");
            break;
          }

          Serial.println("Opened!");
          //File types
          client.println("HTTP/1.1 200 OK");
          if (strstr(filename, ".htm") != 0)
            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) {
            //Serial.print((char)c); //Prints all HTML code to serial (For debuging)
            client.print((char)c); //Prints all HTML code for web page
          }

          //Hit counter math
          if(units >= 2)
          {
            hits ++;
            units = 0;
          }
          units +=1;
          //End hit counter math

          //Print the hit counters and light value
          lcd.setCursor(6, 1);
          lcd.print(hits); //Print hits for LCD hit counter

          client.print("<html><body>"); //HTML code starts here
          client.print("<P align=\"center\">");
          client.print("Hits since reset: <b>");   
          client.print(hits); //Print hits to client
          client.print("</b><br>");

          photocellReading = analogRead(photocellPin);
          client.print("Light reading: ");
          client.print(photocellReading); //Prints light reading to client

          // A few threshholds
          if (photocellReading < 10) {
            client.print(" - Dark");
          }
          else if (photocellReading < 200) {
            client.print(" - Dim");
          }
          else if (photocellReading < 500) {
            client.print(" - Light");
          }
          else if (photocellReading < 800) {
            client.print(" - Bright");
          }
          else {
            client.print(" - Very bright");
          }

          client.print("</p></body></html>"); //HTML code ends here
          //End hit counter and light value

          file.close();

        }
        else {
          client.println("HTTP/1.1 404 Not Found");
          client.println("Content-Type: text/html");
          client.println();
          client.println("<h2>Error 404</h2>");
          client.println("");
        }
        break;
      }
    }
    digitalWrite(greenLEDandBEEP, HIGH);
    delay(1);
    digitalWrite(greenLEDandBEEP, LOW);
    client.stop();
  }

}




understand me?




14  Topics / Home Automation and Networked Objects / Re: Ethernet Shield with index.htm SDcard. on: April 08, 2012, 12:31:15 pm
i zoom, i glad to see you,
 but i think you not understand my question.

On your project, the html is generate throught arduino,
but my case index.htm is open my SDCARD ethrnet shield and i have a Image, i want that when i click on Image , the image turn one led, and when i click again turn of the led.

sorry my english
15  Topics / Home Automation and Networked Objects / Ethernet Shield with index.htm SDcard. on: April 07, 2012, 05:14:00 pm
I found this code which is capable of storing an index.htm file on the SD card's ethernet shield.
I managed to make the point to open the index.htm was this:



Now what I wanted to do was change the code so that when I clicked on  image,  that TURN a one LED,and when i click again  Turn OFF led.
And anyone able to modify this code?

ARDUINO CODE


/*
 * This is a web server that allows you to host a fully functional html
 *  webpage on the World Wide Web.
 * Initial coding was done with the help from the many people in the Arduino community.
 *  Thanks guys!!
 *
 * Arduino Setup: You need an Ethernet Shield SD, and and Arduino.
 *  Optionally pins 8 and 9 can be used for two LEDs that can indicate traffic.
 *
 * SD Card Setup: On the SD card, which must be formated as fat, you must have
 *  an HTML file with the file name of 'index.htm'. All file names on this card
 *  must be written in the old 8.3 file format. In other words, all files must be
 *  named with no more then 8 characters for the name, and 3 for the extension.
 *
 * Note: If you don't know HTML, a good place that I found useful was w3schools
 *  http://www.w3schools.com/html/html_examples.asp
 *
 */

#include <LiquidCrystal.h>
#include <SPI.h>
#include <SdFat.h>
#include <SdFatUtil.h>
#include <Ethernet.h>
#define BUFSIZ 128
#define greenLEDandBEEP 2
#define redLEDpin 3
boolean led2 = true;
int hits = 0; // Set the number of hits the hit counter will start at.
int units = 0;
int count = 0;
int photocellPin = 2;
int photocellReading;
LiquidCrystal lcd(4, 5, 6, 7, 8, 9);

//Local ethernet setup
byte mac[] = {
  0x90, 0xA2, 0xDA, 0x00, 0x1C, 0x0E };
byte ip[] = {
  192, 168, 1, 80 };
char rootFileName[] = "index.htm";
Server server(8080);

//SD card stuff
Sd2Card card;
SdVolume volume;
SdFile root;
SdFile file;
#define error(s) error_P(PSTR(s))
void error_P(const char* str) {
  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() {
  lcd.begin(16, 2);
  lcd.print("Web Server v2.00");
  lcd.setCursor(0, 1);
  lcd.print("Hits:");

  Serial.begin(9600);

  pinMode(greenLEDandBEEP, OUTPUT);
  pinMode(redLEDpin, OUTPUT);

  PgmPrint("Free RAM: ");
  Serial.println(FreeRam()); 

  pinMode(10, OUTPUT);             
  digitalWrite(10, HIGH);             

  if (!card.init(SPI_HALF_SPEED, 4)) error("card.init failed!");

  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();
}


void loop()
{
  if(count >=500)
  { 
    led2 = !led2;
    digitalWrite(redLEDpin, led2);
    count = 0;
  }
  count +=1;

  char clientline[BUFSIZ];
  char *filename;
  int image = 0;
  int index = 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) {
          filename = rootFileName;

        }
        if (strstr(clientline, "GET /") != 0) {
          if (!filename) filename = clientline + 5;

          (strstr(clientline, " HTTP"))[0] = 0;

          Serial.println(filename);

          if (! file.open(&root, filename, O_READ)) {
            client.println("HTTP/1.1 404 Not Found");
            client.println("Content-Type: text/html");
            client.println();
            client.println("<h2>Error 404</h2>");
            client.println("<s2>The file does not exist.<s2>");
            client.println("");
            break;
          }

          Serial.println("Opened!");
          //File types
          client.println("HTTP/1.1 200 OK");
          if (strstr(filename, ".htm") != 0)
            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) {
            //Serial.print((char)c); //Prints all HTML code to serial (For debuging)
            client.print((char)c); //Prints all HTML code for web page
          }

          //Hit counter math
          if(units >= 2)
          {
            hits ++;
            units = 0;
          }
          units +=1;
          //End hit counter math

          //Print the hit counters and light value
          lcd.setCursor(6, 1);
          lcd.print(hits); //Print hits for LCD hit counter

          client.print("<html><body>"); //HTML code starts here
          client.print("<P align=\"center\">");
          client.print("Hits since reset: <b>");   
          client.print(hits); //Print hits to client
          client.print("</b><br>");

          photocellReading = analogRead(photocellPin);
          client.print("Light reading: ");
          client.print(photocellReading); //Prints light reading to client

          // A few threshholds
          if (photocellReading < 10) {
            client.print(" - Dark");
          }
          else if (photocellReading < 200) {
            client.print(" - Dim");
          }
          else if (photocellReading < 500) {
            client.print(" - Light");
          }
          else if (photocellReading < 800) {
            client.print(" - Bright");
          }
          else {
            client.print(" - Very bright");
          }

          client.print("</p></body></html>"); //HTML code ends here
          //End hit counter and light value

          file.close();

        }
        else {
          client.println("HTTP/1.1 404 Not Found");
          client.println("Content-Type: text/html");
          client.println();
          client.println("<h2>Error 404</h2>");
          client.println("");
        }
        break;
      }
    }
    digitalWrite(greenLEDandBEEP, HIGH);
    delay(1);
    digitalWrite(greenLEDandBEEP, LOW);
    client.stop();
  }

}

//The End /*


INDEX.HTML CODE

<html>
<body>

<img src="w3schools.jpg" width="104" height="142" />

</body>
</html>



Pages: [1] 2