J'aimerai utiliser une combinaison de codes "chinés" sur le web, pour m'envoyer une notification Push au travers pushingbox sur mon iphone.
L'idée serait de détecter quelqu'un avec mon arduino émetteur (capteur vibration + IR ), et recevoir sur mon récepteur la trame qui validerai l'envoi du (des) push.
J'arrive à faire fonctionner le code RF, J'arrive à recevoir un push a partir d'une entrée sur arduino+ethernet, mais lorsque j'essaye de mixer les 2 c'est le drame !...
Impossible de piloter ma sortie LED (j'ai aussi mis un relai pour essayer) sur le récepteur, pas d'envoi vers pushingbox non plus, j'ai l'impression que je ne reçoit plus mon "numéro" donné par l'émetteur.
Par contre à la mise sous tension de mon arduino récepteur j'ai bien une notification pushingbox car l'init démarre sur une demande d'envoi, donc ça peut marcher avec un code cohérent.
Pourrez vous m'aider à débogger le code suivant, sachant que je suis novice.
Merci d'avance !
/**************************************************************
* LED reliée en sortie 2.
* Relais en sortie 4.
* Contact relais sortie vers entrée 3.
* Récepteur 433 MHz branché à l'entrée 11.
*Combinaison de :
* http://electroniqueamateur.blogspot.com/2014/01/modules-rf-433-mhz-virtualwire-et.html
*https://github.com/Clement87/PushingBox-for-Spark-Core/blob/master/PushingBox-for-Spark.ino
***************************************************************/
#include <VirtualWire.h>
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x19 }; // Be sure this address is unique in your network
//Your secret DevID from PushingBox.com. You can use multiple DevID on multiple Pin if you want
char DEVID1[] = "v20XXXXXXXXXX"; //Scenario : "The mailbox is open"
//Numeric Pin where you connect your switch
uint8_t pinDevid1 = 3; // Example : the mailbox switch is connect to the Pin 3
// Debug mode
boolean DEBUG = true;
#define LED1 2
#define RELAIS 4
int Nombre;
char Message[VW_MAX_MESSAGE_LEN];
char serverName[] = "api.pushingbox.com";
boolean pinDevid1State = false; // Save the last state of the Pin for DEVID1
boolean lastConnected = false; // State of the connection last time through the main loop
// 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;
void setup() {
vw_setup(2000); // Bits par seconde
vw_rx_start();
Serial.begin(9600);
// initialize the digital pin.
pinMode(RELAIS, OUTPUT);
pinMode(pinDevid1, INPUT);
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
while(true);
}
else{
Serial.println("Ethernet ready");
// print the Ethernet board/shield's IP address:
Serial.print("My IP address: ");
Serial.println(Ethernet.localIP());
}
// give the Ethernet shield a second to initialize:
delay(1000);
}
void loop(){
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen))
{
int i;
for (i = 0; i < buflen; i++)
{
Message[i] = char(buf[i]);
}
Message[buflen] = '\0';
// Conversion du tableau de chars en int:
Nombre = atoi(Message);
if (Nombre == 1){
digitalWrite (LED1,HIGH);
digitalWrite (RELAIS,HIGH);
}
if (Nombre == 4){
digitalWrite (LED1,LOW);
digitalWrite (RELAIS,LOW);
}
}
////
// Listening for the pinDevid1 state
////
if (digitalRead(pinDevid1) == HIGH && pinDevid1State == false) // switch on pinDevid1 is ON
{
if(DEBUG){Serial.println("pinDevid1 is HIGH");}
pinDevid1State = true;
//Sending request to PushingBox when the pin is HIGHT
sendToPushingBox(DEVID1);
}
if (digitalRead(pinDevid1) == LOW && pinDevid1State == true) // switch on pinDevid1 is OFF
{
if(DEBUG){Serial.println("pinDevid1 is LOW");}
pinDevid1State = false;
//Sending request to PushingBox when the pin is LOW
//sendToPushingBox(DEVID1); //Here you can run an other scenario by creating a DEVID2 variable
}
//DEBUG part
// this write the respons from PushingBox Server.
// You should see a "200 OK"
if (client.available()) {
char c = client.read();
if(DEBUG){Serial.print(c);}
}
// if there's no net connection, but there was one last time
// through the loop, then stop the client:
if (!client.connected() && lastConnected) {
if(DEBUG){Serial.println();}
if(DEBUG){Serial.println("disconnecting.");}
client.stop();
}
lastConnected = client.connected();
}
//Function for sending the request to PushingBox
void sendToPushingBox(char devid[]){
client.stop();
if(DEBUG){Serial.println("connecting...");}
if (client.connect(serverName, 80)) {
if(DEBUG){Serial.println("connected");}
if(DEBUG){Serial.println("sendind request");}
client.print("GET /pushingbox?devid=");
client.print(devid);
client.println(" HTTP/1.1");
client.print("Host: ");
client.println(serverName);
client.println("User-Agent: Arduino");
client.println();
}
else {
if(DEBUG){Serial.println("connection failed");}
}
}
Bien vu l'aveugle... et merci pour ton aide !!
Donc je suis maintenant sur de recevoir la valeur : Si ma consigne est à 4 = poursuite de la boucle jusqu'a ma notification mais par contre cela ne boucle pas si je rechange d'état par la suite, cest comme si il avait terminé.
Ethernet ready
My IP address: 192.168.0.1
Reception du nombre = 4
0
pinDevid1 is HIGH
connecting...
connected
sendind request
HTTP/1.1 200 OK
Set-Cookie: 60gpBAK=R122491420; path=/; expires=Tue, 09-Sep-2014 00:10:18 GMT
Date: Mon, 08 Sep 2014 22:56:48 GMT
Content-Type: text/html
Content-Length: 0
Connection: keep-alive
Set-Cookie: 60gp=R233715866; path=/; expires=Tue, 09-Sep-2014 00:10:11 GMT
Server: Apache
Content-Location: pushingbox.php
Vary: negotiate,Accept-Encoding
TCN: choice
X-Powered-By: PHP/5.2.17
Si ma conigne c'est 1 = pas de notification (normal) puis plus rien ne se passe ensuite aux différents changements de consigne (programme arrêté ?).
Ethernet ready
My IP address: 192.168.0.1
Reception du nombre = 1
1
/**************************************************************
* LED reliée en sortie 2.
* Relais en sortie 4.
* Contact relais sortie vers entrée 3.
* Récepteur 433 MHz branché à l'entrée 11.
*Combinaison de :
* http://electroniqueamateur.blogspot.com/2014/01/modules-rf-433-mhz-virtualwire-et.html
*https://github.com/Clement87/PushingBox-for-Spark-Core/blob/master/PushingBox-for-Spark.ino
***************************************************************/
#include <VirtualWire.h>
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x19 }; // Be sure this address is unique in your network
//Your secret DevID from PushingBox.com. You can use multiple DevID on multiple Pin if you want
char DEVID1[] = "v20xxxxxxxxxxx"; //Scenario : "The mailbox is open"
//Numeric Pin where you connect your switch
uint8_t pinDevid1 = 3; // Example : the mailbox switch is connect to the Pin 3
// Debug mode
boolean DEBUG = true;
#define LED1 2
#define RELAIS 4
int Nombre;
char Message[VW_MAX_MESSAGE_LEN];
char serverName[] = "api.pushingbox.com";
boolean pinDevid1State = false; // Save the last state of the Pin for DEVID1
boolean lastConnected = false; // State of the connection last time through the main loop
// 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;
void setup() {
vw_setup(2000); // Bits par seconde
vw_rx_start();
Serial.begin(9600);
// initialize the digital pin.
pinMode(RELAIS, OUTPUT);
pinMode(pinDevid1, INPUT);
// mise à l'état bas des sorties (MAJ08092014).
pinMode(LED1,LOW);
pinMode(RELAIS,LOW);
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
while(true);
}
else{
Serial.println("Ethernet ready");
// print the Ethernet board/shield's IP address:
Serial.print("My IP address: ");
Serial.println(Ethernet.localIP());
}
// give the Ethernet shield a second to initialize:
delay(1000);
}
void loop(){
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen))
{
int i;
for (i = 0; i < buflen; i++)
{
Message[i] = char(buf[i]);
}
Message[buflen] = '\0';
// Conversion du tableau de chars en int:
Nombre = atoi(Message);
Serial.print("Reception du nombre = ");
Serial.println(Nombre);
if (Nombre == 1){
digitalWrite (LED1,HIGH);
digitalWrite (RELAIS,HIGH);
Serial.println(valide nombre 1); //visiblement ne marche pas?
}
if (Nombre == 4){
digitalWrite (LED1,LOW);
digitalWrite (RELAIS,LOW);
Serial.println(valide nombre 4); //visiblement ne marche pas?
}
////
// Listening for the pinDevid1 state
////
if (digitalRead(pinDevid1) == HIGH && pinDevid1State == false && Nombre == 4 ) // switch on pinDevid1 is ON si nombre = 4 (MAJ08092014)
{
if(DEBUG){Serial.println("pinDevid1 is HIGH");}
pinDevid1State = true;
//Sending request to PushingBox when the pin is HIGHT
sendToPushingBox(DEVID1);
}
if (digitalRead(pinDevid1) == LOW && pinDevid1State == true && Nombre == 1 ) // switch on pinDevid1 is OFF si nombre = 1 (MAJ08092014)
{
if(DEBUG){Serial.println("pinDevid1 is LOW");}
pinDevid1State = false;
//Sending request to PushingBox when the pin is LOW
//sendToPushingBox(DEVID1); //Here you can run an other scenario by creating a DEVID2 variable
}
//DEBUG part
// this write the respons from PushingBox Server.
// You should see a "200 OK"
if (client.available()) {
char c = client.read();
if(DEBUG){Serial.print(c);}
}
// if there's no net connection, but there was one last time
// through the loop, then stop the client:
if (!client.connected() && lastConnected) {
if(DEBUG){Serial.println();}
if(DEBUG){Serial.println("disconnecting.");}
client.stop();
}
lastConnected = client.connected();
}
//Function for sending the request to PushingBox
void sendToPushingBox(char devid[]){
client.stop();
if(DEBUG){Serial.println("connecting...");}
if (client.connect(serverName, 80)) {
if(DEBUG){Serial.println("connected");}
if(DEBUG){Serial.println("sendind request");}
client.print("GET /pushingbox?devid=");
client.print(devid);
client.println(" HTTP/1.1");
client.print("Host: ");
client.println(serverName);
client.println("User-Agent: Arduino");
client.println();
}
else {
if(DEBUG){Serial.println("connection failed");}
}
}
salut , je n'ai jamais utiliser la lib virtualwire mais a quel moment defini tu la longueur de ton buffer ?
"VW_MAX_MESSAGE_LEN" car je ne le trouve pas dans le code joint.
Heloderma-kris:
salut , je n'ai jamais utiliser la lib virtualwire mais a quel moment defini tu la longueur de ton buffer ?
"VW_MAX_MESSAGE_LEN" car je ne le trouve pas dans le code joint.
Merci de m'aider, même si j'ai pas trop d'idée vu que c'est mon premier vrai programme (que j'ai nullement tapé d'ailleur..).
Justement je n'avait pas mis le bon lien concernant l'exemple utilisé pour ma compilation, c'est plutot sur cette page :
J'ai maintenant cette erreur je sait pas pourquoi :
//Sending request to PushingBox when the pin is HIGHT
sendToPushingBox(DEVID1)
ERREUR :
RECEPTEUR_MAISON_110914.ino: In function 'void loop()':
RECEPTEUR_MAISON_110914:128: error: 'sendToPushingBox' was not declared in this scope
RECEPTEUR_MAISON_110914:162: error: expected initializer before 'client'
RECEPTEUR_MAISON_110914:170: error: 'devid' was not declared in this scope
Je crois que demain je repars à zéro...
Bonne nuit à tous !
Pas de gros changements, les erreurs précédentes + probleme de bouclage arretant la réception m'empechant de faire plusieurs notifications à la suite...
/**************************************************************
* LED reliée en sortie 2.
* Relais en sortie 4.
* Contact relais sortie vers entrée 3.
* Récepteur 433 MHz branché à l'entrée 11.
*Combinaison de :
* http://electroniqueamateur.blogspot.com/2014/01/modules-rf-433-mhz-virtualwire-et.html
*https://github.com/Clement87/PushingBox-for-Arduino/blob/master/PushingBox_Arduino_Ethernet_Official/PushingBox_Arduino_Ethernet_Official.ino
* voir aussi ici http://skyduino.wordpress.com/2011/12/29/tutoriel-arduino-et-emetteurrecepteur-433mhz-virtualwire/
***************************************************************/
#include <VirtualWire.h>
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x19 }; // Be sure this address is unique in your network
//Your secret DevID from PushingBox.com. You can use multiple DevID on multiple Pin if you want
char DEVID1[] = "v203FA76EFFEFFC3"; //Scenario : "The mailbox is open"
//Numeric Pin where you connect your switch
uint8_t pinDevid1 = 3; // Example : the mailbox switch is connect to the Pin 3
// Debug mode
boolean DEBUG = true;
#define LED1 2
#define RELAIS 4
int Nombre;
char Message[VW_MAX_MESSAGE_LEN];
char serverName[] = "api.pushingbox.com";
boolean pinDevid1State = false; // Save the last state of the Pin for DEVID1
boolean lastConnected = false; // State of the connection last time through the main loop
long lastReadingTime = 0; // MAJ 10092014
// 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;
void setup() {
vw_setup(2000); // Bits par seconde
vw_rx_start();
Serial.begin(9600);
// initialize the digital pin.
pinMode(LED1, OUTPUT);
pinMode(RELAIS, OUTPUT);
pinMode(pinDevid1, INPUT);
// mise à l'état bas des sorties (MAJ08092014).
pinMode(LED1,LOW);
pinMode(RELAIS,LOW);
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
while(true);
}
else{
Serial.println("Ethernet ready");
// print the Ethernet board/shield's IP address:
Serial.print("My IP address: ");
Serial.println(Ethernet.localIP());
}
// give the Ethernet shield a second to initialize:
delay(1000);
}
void loop()
{
Serial.print("début loop");
uint8_t buf[VW_MAX_MESSAGE_LEN]; // Tableau qui va contenir le message reçu (de taille maximum VW_MAX_MESSAGE_LEN)
uint8_t buflen = VW_MAX_MESSAGE_LEN; // Taille maximum de notre tableau
char Message[VW_MAX_MESSAGE_LEN];
if (vw_get_message(buf, &buflen))
{
int i;
for (i = 0; i < buflen; i++)
{
Message[i] = char(buf[i]);
}
Message[buflen] = '\0';
// Conversion du tableau de chars en int:
Nombre = atoi(Message);
Serial.print("Reception du nombre = ");
Serial.println(Nombre);
if (Nombre == 1)
{
digitalWrite (LED1,HIGH);
digitalWrite (RELAIS,HIGH);
Serial.println("valide nombre 1");
}
if (Nombre == 4)
{
digitalWrite (LED1,LOW);
digitalWrite (RELAIS,LOW);
Serial.println("valide nombre 4");
}
////
// Listening for the pinDevid1 state
////
if (digitalRead(pinDevid1) == HIGH && pinDevid1State == false && Nombre == 4 ) // switch on pinDevid1 is ON si nombre = 4 (MAJ08092014)
{
if(DEBUG){Serial.println("pinDevid1 is HIGH");}
pinDevid1State = true;
//Sending request to PushingBox when the pin is HIGHT
sendToPushingBox(DEVID1);
}
if (digitalRead(pinDevid1) == LOW && pinDevid1State == true && Nombre == 1 ) // switch on pinDevid1 is OFF si nombre = 1 (MAJ08092014)
{
if(DEBUG){Serial.println("pinDevid1 is LOW");}
pinDevid1State = false;
//Sending request to PushingBox when the pin is LOW
//sendToPushingBox(DEVID1); //Here you can run an other scenario by creating a DEVID2 variable
}
//DEBUG part
// this write the respons from PushingBox Server.
// You should see a "200 OK"
if (client.available()) {
char c = client.read();
if(DEBUG){Serial.print(c);}
}
// if there's no net connection, but there was one last time
// through the loop, then stop the client:
if (!client.connected() && lastConnected) {
if(DEBUG){Serial.println();}
if(DEBUG){Serial.println("disconnecting.");}
client.stop();
}
lastConnected = client.connected();
}
//Function for sending the request to PushingBox
void sendToPushingBox(char devid[])
client.stop();
if(DEBUG){Serial.println("connecting...");}
if (client.connect(serverName, 80)) {
if(DEBUG){Serial.println("connected");}
if(DEBUG){Serial.println("sendind request");}
client.print("GET /pushingbox?devid=");
client.print(devid);
client.println(" HTTP/1.1");
client.print("Host: ");
client.println(serverName);
client.println("User-Agent: Arduino");
client.println();
}
else {
if(DEBUG){Serial.println("connection failed");}
}
}
bon j'ai corrigé ton plantage de compile , tu avais rentré ta fonction sendPushingBox dans ton loop et en plus le code de la fonction n'etait pas correctement mis entre les accolade:
voic le code qui compile
/**************************************************************
* LED reliée en sortie 2.
* Relais en sortie 4.
* Contact relais sortie vers entrée 3.
* Récepteur 433 MHz branché à l'entrée 11.
*Combinaison de :
* http://electroniqueamateur.blogspot.com/2014/01/modules-rf-433-mhz-virtualwire-et.html
*https://github.com/Clement87/PushingBox-for-Arduino/blob/master/PushingBox_Arduino_Ethernet_Official/PushingBox_Arduino_Ethernet_Official.ino
* voir aussi ici http://skyduino.wordpress.com/2011/12/29/tutoriel-arduino-et-emetteurrecepteur-433mhz-virtualwire/
***************************************************************/
#include <VirtualWire.h>
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x19 }; // Be sure this address is unique in your network
//Your secret DevID from PushingBox.com. You can use multiple DevID on multiple Pin if you want
char DEVID1[] = "v203FA76EFFEFFC3"; //Scenario : "The mailbox is open"
//Numeric Pin where you connect your switch
uint8_t pinDevid1 = 3; // Example : the mailbox switch is connect to the Pin 3
// Debug mode
boolean DEBUG = true;
#define LED1 2
#define RELAIS 4
int Nombre;
char Message[VW_MAX_MESSAGE_LEN];
char serverName[] = "api.pushingbox.com";
boolean pinDevid1State = false; // Save the last state of the Pin for DEVID1
boolean lastConnected = false; // State of the connection last time through the main loop
long lastReadingTime = 0; // MAJ 10092014
// 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;
void setup() {
vw_setup(2000); // Bits par seconde
vw_rx_start();
Serial.begin(9600);
// initialize the digital pin.
pinMode(LED1, OUTPUT);
pinMode(RELAIS, OUTPUT);
pinMode(pinDevid1, INPUT);
// mise à l'état bas des sorties (MAJ08092014).
pinMode(LED1,LOW);
pinMode(RELAIS,LOW);
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
while(true);
}
else{
Serial.println("Ethernet ready");
// print the Ethernet board/shield's IP address:
Serial.print("My IP address: ");
Serial.println(Ethernet.localIP());
}
// give the Ethernet shield a second to initialize:
delay(1000);
}
void loop()
{
Serial.print("début loop");
uint8_t buf[VW_MAX_MESSAGE_LEN]; // Tableau qui va contenir le message reçu (de taille maximum VW_MAX_MESSAGE_LEN)
uint8_t buflen = VW_MAX_MESSAGE_LEN; // Taille maximum de notre tableau
char Message[VW_MAX_MESSAGE_LEN];
if (vw_get_message(buf, &buflen))
{
int i;
for (i = 0; i < buflen; i++)
{
Message[i] = char(buf[i]);
}
Message[buflen] = '\0';
// Conversion du tableau de chars en int:
Nombre = atoi(Message);
Serial.print("Reception du nombre = ");
Serial.println(Nombre);
if (Nombre == 1)
{
digitalWrite (LED1,HIGH);
digitalWrite (RELAIS,HIGH);
Serial.println("valide nombre 1");
}
if (Nombre == 4)
{
digitalWrite (LED1,LOW);
digitalWrite (RELAIS,LOW);
Serial.println("valide nombre 4");
}
////
// Listening for the pinDevid1 state
////
if (digitalRead(pinDevid1) == HIGH && pinDevid1State == false && Nombre == 4 ) // switch on pinDevid1 is ON si nombre = 4 (MAJ08092014)
{
if(DEBUG){Serial.println("pinDevid1 is HIGH");}
pinDevid1State = true;
//Sending request to PushingBox when the pin is HIGHT
sendToPushingBox(DEVID1);
}
if (digitalRead(pinDevid1) == LOW && pinDevid1State == true && Nombre == 1 ) // switch on pinDevid1 is OFF si nombre = 1 (MAJ08092014)
{
if(DEBUG){Serial.println("pinDevid1 is LOW");}
pinDevid1State = false;
//Sending request to PushingBox when the pin is LOW
//sendToPushingBox(DEVID1); //Here you can run an other scenario by creating a DEVID2 variable
}
//DEBUG part
// this write the respons from PushingBox Server.
// You should see a "200 OK"
if (client.available()) {
char c = client.read();
if(DEBUG){Serial.print(c);}
}
// if there's no net connection, but there was one last time
// through the loop, then stop the client:
if (!client.connected() && lastConnected) {
if(DEBUG){Serial.println();}
if(DEBUG){Serial.println("disconnecting.");}
client.stop();
}
lastConnected = client.connected();
}
}//fin du loop
//Function for sending the request to PushingBox
void sendToPushingBox(char*devid){
client.stop();
if(DEBUG){Serial.println("connecting...");}
if (client.connect(serverName, 80)) {
if(DEBUG){Serial.println("connected");}
if(DEBUG){Serial.println("sendind request");}
client.print("GET /pushingbox?devid=");
client.print(devid);
client.println(" HTTP/1.1");
client.print("Host: ");
client.println(serverName);
client.println("User-Agent: Arduino");
client.println();
}
else {
if(DEBUG){Serial.println("connection failed");}
}/// fin de fonction
}
Ok, quand c'est comme ça, il faut reprendre petit bout par petit bout. Commence par ça :
#include <VirtualWire.h>
//Numeric Pin where you connect your switch
uint8_t pinDevid1 = 3; // Example : the mailbox switch is connect to the Pin 3
// Debug mode
boolean DEBUG = true;
#define LED1 2
#define RELAIS 4
int Nombre;
char Message[VW_MAX_MESSAGE_LEN];
boolean pinDevid1State = false; // Save the last state of the Pin for DEVID1
boolean lastConnected = false; // State of the connection last time through the main loop
long lastReadingTime = 0; // MAJ 10092014
void setup() {
vw_setup(2000); // Bits par seconde
vw_rx_start();
Serial.begin(9600);
// initialize the digital pin.
pinMode(LED1, OUTPUT);
pinMode(RELAIS, OUTPUT);
pinMode(pinDevid1, INPUT);
// mise à l'état bas des sorties (MAJ08092014).
pinMode(LED1,LOW);
pinMode(RELAIS,LOW);
}
void loop()
{
Serial.print("début loop");
uint8_t buf[VW_MAX_MESSAGE_LEN]; // Tableau qui va contenir le message reçu (de taille maximum VW_MAX_MESSAGE_LEN)
uint8_t buflen = VW_MAX_MESSAGE_LEN; // Taille maximum de notre tableau
char Message[VW_MAX_MESSAGE_LEN];
if (vw_get_message(buf, &buflen))
{
int i;
for (i = 0; i < buflen; i++)
{
Message[i] = char(buf[i]);
}
Message[buflen] = '\0';
// Conversion du tableau de chars en int:
Nombre = atoi(Message);
Serial.print("Reception du nombre = ");
Serial.println(Nombre);
if (Nombre == 1)
{
digitalWrite (LED1,HIGH);
digitalWrite (RELAIS,HIGH);
Serial.println("valide nombre 1");
}
if (Nombre == 4)
{
digitalWrite (LED1,LOW);
digitalWrite (RELAIS,LOW);
Serial.println("valide nombre 4");
}
}
}
Ensuite tu rajoutes l'initialisation de l'ethernet, puis une requete ethernet simple, puis pushingbox ... le but c'est de cibler où ça déconne