Permalink
Browse files

BUNCH of changes

  • Loading branch information...
1 parent 525f77b commit 00c5a38597eed4b9b3e3ab7a1b7f1d0b92cf5566 @kiilo committed Feb 12, 2012
Showing with 7,453 additions and 64 deletions.
  1. +180 −0 arduino_sketchbook/node_arduino/node_arduino.ino
  2. +87 −64 server.js
  3. +557 −0 static/client03.js
  4. +653 −0 static/css/960.css
  5. +357 −0 static/css/960_12_col.css
  6. +357 −0 static/css/960_12_col_rtl.css
  7. +446 −0 static/css/960_16_col.css
  8. +446 −0 static/css/960_16_col_rtl.css
  9. +621 −0 static/css/960_24_col.css
  10. +621 −0 static/css/960_24_col_rtl.css
  11. +653 −0 static/css/960_rtl.css
  12. +55 −0 static/css/demo.css
  13. +1 −0 static/css/min/960.css
  14. +1 −0 static/css/min/960_12_col.css
  15. +1 −0 static/css/min/960_12_col_rtl.css
  16. +1 −0 static/css/min/960_16_col.css
  17. +1 −0 static/css/min/960_16_col_rtl.css
  18. +1 −0 static/css/min/960_24_col.css
  19. +1 −0 static/css/min/960_24_col_rtl.css
  20. +1 −0 static/css/min/960_rtl.css
  21. +1 −0 static/css/min/reset.css
  22. +1 −0 static/css/min/reset_rtl.css
  23. +1 −0 static/css/min/text.css
  24. +1 −0 static/css/min/text_rtl.css
  25. +211 −0 static/css/reset.css
  26. +211 −0 static/css/reset_rtl.css
  27. +86 −0 static/css/text.css
  28. +86 −0 static/css/text_rtl.css
  29. BIN static/images/ui-bg_flat_0_aaaaaa_40x100.png
  30. BIN static/images/ui-bg_glass_55_fbf9ee_1x400.png
  31. BIN static/images/ui-bg_glass_65_ffffff_1x400.png
  32. BIN static/images/ui-bg_glass_75_dadada_1x400.png
  33. BIN static/images/ui-bg_glass_75_e6e6e6_1x400.png
  34. BIN static/images/ui-bg_glass_75_ffffff_1x400.png
  35. BIN static/images/ui-bg_highlight-soft_75_cccccc_1x100.png
  36. BIN static/images/ui-bg_inset-soft_95_fef1ec_1x100.png
  37. BIN static/images/ui-icons_222222_256x240.png
  38. BIN static/images/ui-icons_2e83ff_256x240.png
  39. BIN static/images/ui-icons_454545_256x240.png
  40. BIN static/images/ui-icons_888888_256x240.png
  41. BIN static/images/ui-icons_cd0a0a_256x240.png
  42. BIN static/img/12_col.gif
  43. BIN static/img/16_col.gif
  44. BIN static/img/24_col.gif
  45. +4 −0 static/jquery-1.7.1.min.js
  46. +565 −0 static/jquery-ui-1.8.17.custom.css
  47. +356 −0 static/jquery-ui-1.8.17.custom.min.js
  48. BIN static/powerOFF.png
  49. +45 −0 static/powerOFF.svg
  50. BIN static/powerON.png
  51. +54 −0 static/powerON.svg
  52. +185 −0 static/style.css
  53. +605 −0 static/switch03.html
@@ -0,0 +1,180 @@
+
+
+/*
+
+ node arduino
+
+ This sketch connects to a node.js sevice listening on a TCP port
+ using an Arduino Wiznet Ethernet shield. Implenting a simple Ascii
+ based potocol.
+
+ Protocol:
+ * o Pin Status :: digitalWrite(Pin, Status) // output from arduino
+ * m Pin Mode :: pinMode( Pin, Mode) // 0:input 1:output
+ * r Pin Enable :: analogRead(Pin) // 0:disable 1:enable
+
+ * a Pin Reading :: if analog enabled (see "r") every 200ms
+ * i Pin Status :: if digital input mode input (see "m") evey 200ms
+
+ data is only send out when there are changes fom prior readings
+
+ Circuit:
+ * Ethernet shield attached to pins 10, 11, 12, 13
+
+ created 11 Feb 2011
+ by kiilo (Tobias Hoffmann)
+
+ */
+
+#include <SPI.h>
+#include <Ethernet.h>
+#include <TextFinder.h>
+
+// Enter a MAC address for your controller below.
+// Newer Ethernet shields have a MAC address printed on a sticker on the shield
+byte mac[] = {
+ 0x00, 0xAA, 0xBB, 0xCC, 0xDA, 0x03 };
+IPAddress server(192, 168, 42, 62);
+
+// Initialize the Ethernet client library
+// with the IP address and port of the server
+// that you want to connect to (port 80 is default for HTTP):
+EthernetClient client;
+TextFinder finder(client, 1);
+
+int Pin = 13;
+int Mode = 1;
+int Status;
+int PinModes[] = {
+ -1, -1, 1, 1, 1, 1, 1, 1, 1, 1}; // , 1, 1, 1, 1}; // 10 -13 allready used
+int PinStatus[] = {
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; // , 0, 0, 0, 0}; // dito
+int AnalogEnable[] = {
+ 0, 0, 0, 0, 0, 0};
+int Analog;
+int AnalogStatus[] = { -1, -1, -1, -1, -1, -1}; // it will update on first reading
+
+long UpdateTimer = 0;
+int UpdateInterval = 200;
+
+// Initialize the Ethernet client library
+// with the IP address and port of the server
+// that you want to connect to (port 80 is default for HTTP):
+//client.connect(server, 7000);
+
+
+
+void setup() {
+ // start the Ethernet connection:
+ Ethernet.begin(mac);
+ // start the serial library:
+ Serial.begin(9600);
+ // give the Ethernet shield a second to initialize:
+ delay(1000);
+ Serial.println("connecting...");
+
+ // if you get a connection, report back via serial:
+ if (client.connect("kiilo.org", 7000)) {
+ Serial.println("connected");
+ // send secret key fo auth:
+ client.println("k BC37ACB390EF2");
+ TextFinder finder( client);
+ }
+ else {
+ // kf you didn't get a connection to the server:
+ Serial.println("connection failed");
+ }
+}
+
+void loop()
+{
+ // if there are incoming bytes available
+ // from the server, read them and print them:
+
+ // INCOMING MESSAGES //////////////////////////////////////////////////
+ while (client.available()) {
+ char c = client.read();
+ Serial.print(c);
+
+ if( c == 'o') { // o Pin PinStatus :: output pin
+ Pin = finder.getValue();
+ PinStatus[Pin] = finder.getValue();
+ if (PinModes[Pin] > 0) {
+ digitalWrite(Pin, PinStatus[Pin]);
+ }
+ }
+ if( c == 'm') { // m Pin PinMode :: PinMode change pin mode
+ Pin = finder.getValue();
+ Mode = finder.getValue();
+ PinModes[Pin] = Mode;
+ pinMode(Pin, Mode);
+ }
+ if( c == 'r') { // r Pin AnalogEnable :: analog pin enable
+ Pin = finder.getValue();
+ AnalogEnable[Pin] = finder.getValue();
+ }
+
+ }
+
+ // OUTGOING MESSAGES /////////////////////////////////////////////////
+ if (UpdateTimer < millis()) {
+ UpdateTimer = millis() + UpdateInterval;
+
+ for(Pin = 2; Pin < 10; Pin++) {
+ if(PinModes[Pin] == 0) {
+ Status = digitalRead(Pin);
+ if (Status != PinStatus[Pin]) {
+ PinStatus[Pin] = Status;
+ client.write("i ");
+ client.write(Pin + '0');
+ client.write(" ");
+ client.write(Status + '0');
+ client.write("\n");
+ }
+ }
+ }
+
+ for(Pin = 0; Pin < 6; Pin++) {
+ if(AnalogEnable[Pin]) {
+ Analog = analogRead(Pin);
+ if (Analog != AnalogStatus[Pin]) {
+ AnalogStatus[Pin] = Analog;
+ client.write("a ");
+ client.write(Pin + '0');
+ client.write(" ");
+ client.print(Analog);
+ client.write("\n");
+ }
+ }
+ }
+
+ }
+
+ while (Serial.available()) {
+ char c = Serial.read();
+ client.print(c);
+ }
+ // if (millis() > PingTimer) {
+ // PingTimer = millis() + 5000;
+ // client.print("PING ");
+ // client.println(PingTimer);
+ // }
+ // if the server's disconnected, stop the client:
+ if (!client.connected()) {
+ Serial.println();
+ Serial.println("disconnecting. DEAD!!");
+ client.stop();
+
+ // do nothing forevermore:
+ for(;;)
+ ;
+ }
+}
+
+
+
+
+
+
+
+
Oops, something went wrong.

0 comments on commit 00c5a38

Please sign in to comment.