@ -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 |
@ -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 <Adafruit_NeoPixel.h> | |||
#ifdef __AVR__ | |||
#include <avr/power.h> | |||
#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<NUMPIXELS;i++){ | |||
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255 | |||
pixels.setPixelColor(i, pixels.Color(50,150,50)); // Moderately bright green color. | |||
pixels.show(); // This sends the updated pixel color to the hardware. | |||
delay(delayval); // Delay for a period of time (in milliseconds). | |||
} | |||
} |
@ -0,0 +1,43 @@ | |||
/* | |||
* NOTE: this test is for HFS-DC06H | |||
* | |||
* ZMHW Changes: | |||
* | |||
* Using pin 4. This might change depending on PCB revision. Double | |||
* check. | |||
* | |||
* If the Digital Hi (reads as 1's in serial) doesn't go away, and you are using USB, | |||
* you might need external power. Some USB is not enough. | |||
* Especially when ethernet is active. | |||
* Ethernet draws power, even if library is not active. | |||
*/ | |||
/* | |||
DigitalReadSerial | |||
Reads a digital input on pin 2, prints the result to the serial monitor | |||
This example code is in the public domain. | |||
*/ | |||
// digital pin 2 has a pushbutton attached to it. Give it a name: | |||
int MotionSensor = 4; | |||
// the setup routine runs once when you press reset: | |||
void setup() { | |||
// initialize serial communication at 9600 bits per second: | |||
Serial.begin(9600); | |||
// make the pushbutton's pin an input: | |||
pinMode(MotionSensor, INPUT); | |||
} | |||
// the loop routine runs over and over again forever: | |||
void loop() { | |||
// read the input pin: | |||
int MotionState = digitalRead(MotionSensor); | |||
// print out the state of the button: | |||
Serial.println(MotionState); | |||
delay(100); // delay in between reads for stability | |||
} | |||
@ -0,0 +1,111 @@ | |||
/* | |||
Same as default library but uses UIPEthernet. Requires UIPEthernet. | |||
Manage Libraries - Download UIP Ethernet library | |||
*/ | |||
/* | |||
Web Server | |||
A simple web server that shows the value of the analog input pins. | |||
using an Arduino Wiznet Ethernet shield. | |||
Circuit: | |||
* Ethernet shield attached to pins 10, 11, 12, 13 | |||
* Analog inputs attached to pins A0 through A5 (optional) | |||
created 18 Dec 2009 | |||
by David A. Mellis | |||
modified 9 Apr 2012 | |||
by Tom Igoe | |||
modified 02 Sept 2015 | |||
by Arturo Guadalupi | |||
*/ | |||
#include <SPI.h> | |||
#include <UIPEthernet.h> | |||
// 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("<!DOCTYPE HTML>"); | |||
client.println("<html>"); | |||
// 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("<br />"); | |||
} | |||
client.println("</html>"); | |||
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"); | |||
} | |||
} | |||