Bonjours, Je suis actuellement entrain de réalisé un projet : l'Aquarium Intelligent oùl'aquarium doit changé l'eau, donnée à mangé , prendre la température, prendre des photos etc ... Donc tout les programmes sont déjà fait, mais la dernière tache est d'assemblé tout les programmes !
j'ai déjà essayé d'assemblé les programmes mes rien ne fonctionne ou (juste les servo moteurs fonctionne) ..
Programme du Webserver pour afficher la température et les 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'>");
}
// 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();
}
}
Programme des servo moteurs pour le changement d'eau et pour nourrir les poissons:
#include <Servo.h>
Servo changementdeau; // create servo object to control a servo
Servo nourriture; // a maximum of eight servo objects can be created
int pos = 0; // variable to store the servo position
void setup()
{
changementdeau.attach(9); // attaches 2 servo on pin 9 to the servo object
nourriture(6); // attaches the servo on pin 6 to the servo object
}
void loop()
{
nourriture.write(50);
delay(20);
delay(1000);
nourriture.write(0);
delay(20);
delay(5040000); // waits 2 weeks to restart the servo (tout les 2 semaines il y aura un changement d'eau)
// goes from 0 degrees to 90 degrees
changementdeau.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
changementdeau.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 (tout les 6 heures l'aquarium va nourrir les poissons)
}
Merci D'Avance !