Étape 3: Étape #3: Sketch Arduino
Il s’agit de l’esquisse d’échantillon j’ai édité basé sur ce sitehttp://trollmaker.com/article11/Arduino-1-0-with-ENC28J60-Ethernet-Shield-v1-1
J’ai fait quelques modifications de mon cru, mais il y a une position des boutons pour la LED 2 j’ai modifier pas puisque je vais utiliser mon propre programme android pour ce projet. l’idée est d’obtenir ont les paramètres (tels que la «? led1 = on ") pour travailler sur les conditions d’éclairage.
Un serveur web simple qui transforment un voyant allumé ou éteint"
#include « etherShield.h »
#include « ETHER_28J60.h »
int outputPin1 = 6 ;
int outputPin2 = 7 ;
mac uint8_t statique [6] = {0 x 54, 0 x 55, 0 x 58, 0 x 10, 0 x 00, 0 x 24} ; Cela doit juste être unique pour votre réseau,
uint8_t statique ip [4] = {192, 168, 1, 15} ; Adresse IP pour le serveur Web
public static uint16_t port = 80 ; Utiliser le port 80 - la norme pour HTTP
E ETHER_28J60 ;
void setup()
{
e.Setup (mac, ip, port) ;
pinMode (outputPin1, sortie) ;
pinMode (outputPin2, sortie) ;
}
void loop()
{
char * params ;
Si (params = e.serviceRequest())
{
e.Print ("< h1 >< a href ='/? a conduit = off'> Arduino Web distant < /a >< / h1 >") ;
Si (strcmp (params, «? led1 = on ") == 0)
{
digitalWrite (outputPin1, HIGH) ;
e.Print ("< a href ='? led1 = off' >< bouton style ='border : 1px solid #ff0000 ; border-left : 10px solid #ff0000 "type = « button » > allumée IS < / bouton >< /a >") ;
}
else if (strcmp (params, «? led1 = off ") == 0)
{
digitalWrite (outputPin1, basse) ;
e.Print ("< a href ='? led1 = on' >< bouton style ='border : 1px solid #000 ; border-left : 10px solid #000' type = « button » > LED est éteinte < / bouton >< /a > ") ;
}
else if (strcmp (params, «? led2 = on ") == 0)
{
digitalWrite (outputPin2, HIGH) ;
e.Print ("< a href ='? led2 = off' >< bouton style ='border : 1px solid #ff0000 ; border-left : 10px solid #ff0000 "type = « button » > allumée IS < / bouton >< /a >") ;
}
else if (strcmp (params, «? led2 = off ") == 0)
{
digitalWrite (outputPin2, basse) ;
e.Print ("< a href ='? led2 = sur ' >< bouton style ='border : 1px solid #000 ; border-left : 10px solid #000' type = « button » > LED est éteinte < / bouton >< /a > ") ;
}
e.respond() ;
}
}