diff --git a/ZMHW_Project_InfraredDiodeSensor.ino b/ZMHW_Project_InfraredDiodeSensor.ino index fcbdb33..c5eb450 100644 --- a/ZMHW_Project_InfraredDiodeSensor.ino +++ b/ZMHW_Project_InfraredDiodeSensor.ino @@ -15,8 +15,8 @@ /* * What it does: * Works with accompanying shield to act as motion sensor - * for Zoneminder via ZMTrigger. Shield is optional if you - * want to bother with a perf board and components instead. + * for Zoneminder via ZMTrigger. Shield is optional but recommended + * as it's easier to build. * * Components: * ENC28J60 diff --git a/testsuite/README b/testsuite/README new file mode 100644 index 0000000..5059542 --- /dev/null +++ b/testsuite/README @@ -0,0 +1,15 @@ +Test Suite. +In this folder, is a few example sketches that can be run to verify +that everything works on your ZMHW motion detector. + +There is the following: + + +Web Server test - To test ENC28J60 connectivity + +RGB test - To test the RGB LED + +Motion Sensor test - To test the motion sensor is working + + +TODO: LM35 test \ No newline at end of file diff --git a/testsuite/RGBTest/RGBTest.ino b/testsuite/RGBTest/RGBTest.ino new file mode 100644 index 0000000..d58b201 --- /dev/null +++ b/testsuite/RGBTest/RGBTest.ino @@ -0,0 +1,57 @@ +/* + * ZMHW Changes: + * Use the appropriate pin. + * Make sure to alight all three colours. Bad connections can cause + * some colours to fail, but others will work, so we always want + * to test all three RGB values. Not just one. + * + */ + + +// NeoPixel Ring simple sketch (c) 2013 Shae Erisson +// released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library + +#include +#ifdef __AVR__ + #include +#endif + +// Which pin on the Arduino is connected to the NeoPixels? +// On a Trinket or Gemma we suggest changing this to 1 +#define PIN 5 + +// How many NeoPixels are attached to the Arduino? +#define NUMPIXELS 1 + +// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals. +// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest +// example for more information on possible values. +Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); + +int delayval = 500; // delay for half a second + +void setup() { + // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket +#if defined (__AVR_ATtiny85__) + if (F_CPU == 16000000) clock_prescale_set(clock_div_1); +#endif + // End of trinket special code + + pixels.begin(); // This initializes the NeoPixel library. +} + +void loop() { + + // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one. + + for(int i=0;i +#include + +// Enter a MAC address and IP address for your controller below. +// The IP address will be dependent on your local network: +byte mac[] = { + 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED +}; +IPAddress ip(192, 168, 1, 177); + +// Initialize the Ethernet server library +// with the IP address and port you want to use +// (port 80 is default for HTTP): +EthernetServer server(80); + +void setup() { + // Open serial communications and wait for port to open: + Serial.begin(9600); + while (!Serial) { + ; // wait for serial port to connect. Needed for native USB port only + } + + + // start the Ethernet connection and the server: + Ethernet.begin(mac, ip); + server.begin(); + Serial.print("server is at "); + Serial.println(Ethernet.localIP()); +} + + +void loop() { + // listen for incoming clients + EthernetClient client = server.available(); + if (client) { + Serial.println("new client"); + // an http request ends with a blank line + boolean currentLineIsBlank = true; + while (client.connected()) { + if (client.available()) { + char c = client.read(); + Serial.write(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 you can send a reply + if (c == '\n' && currentLineIsBlank) { + // send a standard http response header + client.println("HTTP/1.1 200 OK"); + client.println("Content-Type: text/html"); + client.println("Connection: close"); // the connection will be closed after completion of the response + client.println("Refresh: 5"); // refresh the page automatically every 5 sec + client.println(); + client.println(""); + client.println(""); + // output the value of each analog input pin + for (int analogChannel = 0; analogChannel < 6; analogChannel++) { + int sensorReading = analogRead(analogChannel); + client.print("analog input "); + client.print(analogChannel); + client.print(" is "); + client.print(sensorReading); + client.println("
"); + } + client.println(""); + 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); + // close the connection: + client.stop(); + Serial.println("client disconnected"); + } +} +