Talk:OpenDuino
From syn2cat - HackerSpace.lu
temporary storage for source code of arduino part:
#include <Ethernet.h> byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; byte ip[] = { 192, 168, 1, 99 }; byte gateway[] = { 192 ,168 ,1 ,254 }; byte subnet[] = { 255, 255, 255, 0 }; boolean open = false; //byte server_ip[] = {74, 125, 127, 100}; //google byte server_ip[] = { 80, 90, 47, 170 }; //hackerspace.lu //byte server_ip[] = { 192, 168, 1, 65 }; char request[300] = "GET /OpenDuino.php?status=0 HTTP/1.0"; //char request[300] = "GET /index.html HTTP/1.0"; unsigned long time = 0; unsigned long oldtime = 0; unsigned long trigger_oldtime = 0; //Server server(1337); void setup() { Ethernet.begin(mac, ip, gateway, subnet); //server.begin(); Serial.begin(9600); lights(); // connect once on launch dialup(); oldtime = millis(); } void dialup() { Client client(server_ip,80); Serial.println("Connecting..."); Serial.println(request); if( client.connect() ){ client.println(request); client.println(); } else { Serial.println("Connection failed."); } //*/ if(client.available()) { char c = client.read(); Serial.println(c); } //*/ client.stop(); } void lights() { if( open ) { digitalWrite(7,HIGH); digitalWrite(5,LOW); } else { digitalWrite(7,LOW); digitalWrite(5,HIGH); } } void loop() { time = millis(); // read the switch state if(digitalRead(0) == 0) { if( time - trigger_oldtime > 1000 || time - trigger_oldtime < 0 ) { trigger_oldtime = time; Serial.println("Changing state."); open = !open; request[26] = (int)open+48; lights(); dialup(); } } // send regular updates if( time-oldtime > 300000 || time - oldtime < 0 ) { oldtime = time; dialup(); } }
- [History↑]
You cannot post new threads to this discussion page because it has been protected from new threads.
Contents
Thread title | Replies | Last modified |
---|---|---|
Alternative OpenDuino authentication | 2 | 20:24, 23 May 2011 |
temporary storage for source code of arduino part:
#include <Ethernet.h> byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; byte ip[] = { 192, 168, 1, 99 }; byte gateway[] = { 192 ,168 ,1 ,254 }; byte subnet[] = { 255, 255, 255, 0 }; boolean open = false; //byte server_ip[] = {74, 125, 127, 100}; //google byte server_ip[] = { 80, 90, 47, 170 }; //hackerspace.lu //byte server_ip[] = { 192, 168, 1, 65 }; char request[300] = "GET /OpenDuino.php?status=0 HTTP/1.0"; //char request[300] = "GET /index.html HTTP/1.0"; unsigned long time = 0; unsigned long oldtime = 0; unsigned long trigger_oldtime = 0; //Server server(1337); void setup() { Ethernet.begin(mac, ip, gateway, subnet); //server.begin(); Serial.begin(9600); lights(); // connect once on launch dialup(); oldtime = millis(); } void dialup() { Client client(server_ip,80); Serial.println("Connecting..."); Serial.println(request); if( client.connect() ){ client.println(request); client.println(); } else { Serial.println("Connection failed."); } //*/ if(client.available()) { char c = client.read(); Serial.println(c); } //*/ client.stop(); } void lights() { if( open ) { digitalWrite(7,HIGH); digitalWrite(5,LOW); } else { digitalWrite(7,LOW); digitalWrite(5,HIGH); } } void loop() { time = millis(); // read the switch state if(digitalRead(0) == 0) { if( time - trigger_oldtime > 1000 || time - trigger_oldtime < 0 ) { trigger_oldtime = time; Serial.println("Changing state."); open = !open; request[26] = (int)open+48; lights(); dialup(); } } // send regular updates if( time-oldtime > 300000 || time - oldtime < 0 ) { oldtime = time; dialup(); } }
temporary storage for source code of arduino part:
#include <Ethernet.h> byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; byte ip[] = { 192, 168, 1, 99 }; byte gateway[] = { 192 ,168 ,1 ,254 }; byte subnet[] = { 255, 255, 255, 0 }; boolean open = false; //byte server_ip[] = {74, 125, 127, 100}; //google byte server_ip[] = { 80, 90, 47, 170 }; //hackerspace.lu //byte server_ip[] = { 192, 168, 1, 65 }; char request[300] = "GET /OpenDuino.php?status=0 HTTP/1.0"; //char request[300] = "GET /index.html HTTP/1.0"; unsigned long time = 0; unsigned long oldtime = 0; unsigned long trigger_oldtime = 0; //Server server(1337); void setup() { Ethernet.begin(mac, ip, gateway, subnet); //server.begin(); Serial.begin(9600); lights(); // connect once on launch dialup(); oldtime = millis(); } void dialup() { Client client(server_ip,80); Serial.println("Connecting..."); Serial.println(request); if( client.connect() ){ client.println(request); client.println(); } else { Serial.println("Connection failed."); } //*/ if(client.available()) { char c = client.read(); Serial.println(c); } //*/ client.stop(); } void lights() { if( open ) { digitalWrite(7,HIGH); digitalWrite(5,LOW); } else { digitalWrite(7,LOW); digitalWrite(5,HIGH); } } void loop() { time = millis(); // read the switch state if(digitalRead(0) == 0) { if( time - trigger_oldtime > 1000 || time - trigger_oldtime < 0 ) { trigger_oldtime = time; Serial.println("Changing state."); open = !open; request[26] = (int)open+48; lights(); dialup(); } } // send regular updates if( time-oldtime > 300000 || time - oldtime < 0 ) { oldtime = time; dialup(); } }
temporary storage for source code of arduino part:
#include <Ethernet.h> byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; byte ip[] = { 192, 168, 1, 99 }; byte gateway[] = { 192 ,168 ,1 ,254 }; byte subnet[] = { 255, 255, 255, 0 }; boolean open = false; //byte server_ip[] = {74, 125, 127, 100}; //google byte server_ip[] = { 80, 90, 47, 170 }; //hackerspace.lu //byte server_ip[] = { 192, 168, 1, 65 }; char request[300] = "GET /OpenDuino.php?status=0 HTTP/1.0"; //char request[300] = "GET /index.html HTTP/1.0"; unsigned long time = 0; unsigned long oldtime = 0; unsigned long trigger_oldtime = 0; //Server server(1337); void setup() { Ethernet.begin(mac, ip, gateway, subnet); //server.begin(); Serial.begin(9600); lights(); // connect once on launch dialup(); oldtime = millis(); } void dialup() { Client client(server_ip,80); Serial.println("Connecting..."); Serial.println(request); if( client.connect() ){ client.println(request); client.println(); } else { Serial.println("Connection failed."); } //*/ if(client.available()) { char c = client.read(); Serial.println(c); } //*/ client.stop(); } void lights() { if( open ) { digitalWrite(7,HIGH); digitalWrite(5,LOW); } else { digitalWrite(7,LOW); digitalWrite(5,HIGH); } } void loop() { time = millis(); // read the switch state if(digitalRead(0) == 0) { if( time - trigger_oldtime > 1000 || time - trigger_oldtime < 0 ) { trigger_oldtime = time; Serial.println("Changing state."); open = !open; request[26] = (int)open+48; lights(); dialup(); } } // send regular updates if( time-oldtime > 300000 || time - oldtime < 0 ) { oldtime = time; dialup(); } }