Hi !! I'm actually in a Project , trying to make a Intelligent Aquarium, with changing the water with the servo motors, then to feed the fish also with the servo motor and take the temperature ... etc ..
so I have all these program but I would like to assemble these programs together !
I already tried but just the servo motors program has worked . Plz help me !
Code of Webserver to show the temperature and the photos :
#include <SPI.h>
#include <Ethernet.h>
float temp = 0;
int sensorValues = 0;
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
0x90, 0xA2, 0xDA, 0xDE, 0xFE, 0x6 };
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 Leonardo 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 (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");
client.println("Refresh: 5");
client.println();
client.println("<!DOCTYPE HTML>");
client.println("<html>");
}
float reading = analogRead(sensorValues);
float voltage = reading * 5.0 / 1024;
float temp = (voltage) * 100;
client.println("<div align='center'>");
client.println("<table border='20' width='70%'>");
client.println("<center><h2>VOTRE AQUARIUM !</h2></center>");
client.println("<center></center>");
client.println("<tr>");
client.println("<td><h3>TEMPERATURE </h3></td>");
client.print("</td><td>");
client.print(temp);
client.println(" *c");
client.println("<META HTTP-EQUIP=\'Refresh\' CONTENT=\'5\'>");
client.println("</td></tr>");
client.println("<tr>");
client.println("<td><h3> PHOTO <h3></td>");
client.println("<img src='c:DSC07965.JPG'>");
break;
}
// you're starting a new line
currentLineIsBlank = true;
}
// you've gotten a character on the current line
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
}
}
Code of servo motors to water changing and to feed the fish :
#include <Servo.h>
Servo waterchanging; // create servo object to control a servo
Servo feed; // a maximum of eight servo objects can be created
int pos = 0; // variable to store the servo position
void setup()
{
waterchanging.attach(9); // attaches 2 servo on pin 9 to the servo object
feed.attach(6); // attaches the servo on pin 6 to the servo object
}
void loop()
{
feed.write(50);
delay(20);
delay(1000);
feed.write(0);
delay(20);
delay(5040000); //waits 2 weeks to restart the servo
// goes from 0 degrees to 90 degrees
waterchanging.write(90); // tell servo to go to position in variable 'pos'
delay(20); // waits 20ms for the servo to reach the position
delay(15000);
// goes from 90 degrees to 0 degrees
waterchanging.write(0); // tell servo to go to position in variable 'pos'
delay(20);
// waits 20ms for the servo to reach the position
delay(2160000); // waits 6 hours to restart the servo
}