Étape 6: Prêt du logiciel
Maintenant, nous allons télécharger le logiciel
(이제 프로그램을 올려볻겠습니다)
Il y a 3 code de programme pour galileo intel Gen 2
(갈릴레오 2세대에서 작동 시킬 수 있는 3가지 코드가 있습니다)
Le premier est l’article Intelligent
(처음은 지능형 부분입니다)
///////////////////////////////////////////////
void setup() {}
initialiser une communication série 9600 bits par seconde : Serial.begin(9600) ; pinMode (sortie 2) ; pinMode (3, sortie) ; pinMode (13, sortie) ; }
la routine de la boucle s’exécute maintes et maintes fois pour toujours : void loop() {/ / lecture de l’entrée sur la broche analogique 0: / / / installation Intelligent / / / int sensorValue1 = analogRead(A0) ; int sensorValue2 = analogRead(A2) ; Serial.println(sensorValue1) ; Serial.println("") ; Serial.println("") ; Serial.println("") ; Serial.println(sensorValue2) ;
///////////////////////// DISTANCE SENSOR //////////////////////////////////
Si (sensorValue2 < 50) {digitalWrite (2, HIGH); digitalWrite (13, HIGH);} ElseIf (sensorValue2 > 50) {digitalWrite (2, basse); digitalWrite (13, faible);} / / / LIGHT SENSOR / / / si (sensorValue1 < 20) {digitalWrite (3, HIGH); digitalWrite (12, HIGH);} ElseIf (sensorValue1 > 100) {digitalWrite (3, faible); digitalWrite (12, faible);}}
/////////////////////////////////////////
Maintenant, voici la Section serveur Web
(이제 웹서버 부분입니다)
///////////////////////////////////////////////////////
#include
#include
la mac de Byte [] = {0x98, 0x4F, 0xEE, 0 x 01, 0 x 81, 0xF2} ; IPAddress ip(192,168,10,20) ; la passerelle de Byte [] = {192, 168, 10, 1} ; sous-réseau Byte = {255, 255, 255, 0} ;
String inString = String(35) ;
Chaîne de Led ;
int a conduit [] = {00, 2, 3, 4, 5, 6, 7, 8, 9} ; int numofleds = 8 ; Valeur de String() = {"on", "marche", "on", "on", "marche", "on", "marche", "on", "marche"} ; EthernetServer server(80) ; Données de type chaîne ; void setup() {Serial.begin(9600) ; Ethernet.Begin (mac, ip) ; Server.Begin() ; mode de pin pour la valeur (int j = 1; j < (numofleds + 1); j ++) {pinMode (sortie led [j,]);} Serial.println ("Serial READY") ; Serial.println ("Ethernet READY") ; Serial.println ("Server READY") ; }
void loop() {EthernetClient client = server.available() ; if(client) {/ / une requête http se termine par un current_line_is_blank booléenne ligne vide = true ; while (client.connected()) {if(client.available()) {char c = client.read(); / / si nous avons appris à la fin de la ligne (a reçu un saut de ligne / / character) et la ligne est vide, la requête http est terminée, / / afin que nous puissions envoyer une réponse si (inString.length() < 35) {inString.concat(c);} si (c == « \n » & & current_line_is_blank) {/ / Envoyer un client.println d’en-tête de réponse http standard ("HTTP / 1.1 200 OK ") ; client.println ("Content-Type : text/html") ; client.println() ; client.println("
"); client.println("
Contrôleur d’Automation Home
"); pour (int j’ai = 1; j’ai < (numofleds + 1); i ++) {Led = String("Appliance") + i; if(inString.indexOf(Led+"=on") > 0 || inString.indexOf("all=on") > 0) {Serial.println(Led+"on") ; digitalWrite (conduit [i], HIGH); valeur [i] = "off";} d’autre if(inString.indexOf(Led+"=off") > 0 || inString.indexOf("all=off") > 0) {Serial.println(Led+"on") ; digitalWrite (conduit [i], LOW); valeur [i] = "on";} client.println ("
« + Led + » ");} client.println("
Tous les ") ; client.println("
"); rupture ; {Si (c == '\n') {/ / nous commençons une nouvelle current_line_is_blank de ligne = true;} ElseIf (c! = '\r') {/ / nous avons obtenu un personnage sur le current_line_is_blank de ligne actuel = false;}} } / / donner le temps de navigateur web pour recevoir les delay(1) de données ; inString = "" ; client.Stop() ; } }
////////////////////////////////////////////////////
Maintenant, est la combinaison de deux code
(두가지를 한번에 수행하는 코드 입니다)
////////////////////////////////////////////////////
#include
#include //network NB: broches, 10, 11, 12 et 13 sont réservées aux module Ethernet. la mac de Byte [] = {0x98, 0x4F, 0xEE, 0 x 01, 0 x 81, 0xF2} ; IPAddress ip(192,168,10,20) ; la passerelle de Byte [] = {192, 168, 10, 1} ; sous-réseau Byte = {255, 255, 255, 0} ;
String inString = String(35) ;
Chaîne de Led ;
int a conduit [] = {00, 2, 3, 4, 5, 6, 7, 8, 9} ; Épingles à LED num 0 à arry n’est pas utilisé int numofleds = 8 ; numofleds valeur String() = {"on", "marche", "on", "on", "marche", "on", "marche", "on", "marche"} ; démarrage tout animé sont éteints
EthernetServer server(80) ; Données de type chaîne ; void setup() {Serial.begin(9600) ; Ethernet.Begin (mac, ip) ; Server.Begin() ; mode de pin pour la valeur (int j = 1; j < (numofleds + 1); j ++) {pinMode (sortie led [j,]);} Serial.println ("Serial READY") ; Serial.println ("Ethernet READY") ; Serial.println ("Server READY") ; }
void loop() {int sensorValue1 = analogRead(A0) ; int sensorValue2 = analogRead(A2) ; if (sensorValue2 < 50) {digitalWrite (2, HIGH); digitalWrite (13, HIGH);} ElseIf (sensorValue2 > 50) {digitalWrite (2, basse); digitalWrite (13, faible);} / / / LIGHT SENSOR / / / si (sensorValue1 < 20) {digitalWrite (3, HIGH); digitalWrite (12, HIGH);} ElseIf (sensorValue1 > 100) {digitalWrite (3, faible); digitalWrite (12, faible);} EthernetClient client = server.available() ; if(client) {/ / une requête http se termine par un current_line_is_blank booléenne ligne vide = true ; while (client.connected()) {if(client.available()) {char c = client.read(); / / si nous avons appris à la fin de la ligne (a reçu un saut de ligne / / character) et la ligne est vide, la requête http est terminée, / / afin que nous puissions envoyer une réponse si (inString.length() < 35) {inString.concat(c);} si (c == « \n » & & current_line_is_blank) {/ / Envoyer un client.println d’en-tête de réponse http standard ("HTTP/1.1 200 OK"); client.println ("Content-Type : text/html ") ; client.println() ; client.println("
"); client.println("
Contrôleur d’Automation Home
"); pour (int j’ai = 1; j’ai < (numofleds + 1); i ++) {Led = String("led") + i; if(inString.indexOf(Led+"=on") > 0 || inString.indexOf("all=on") > 0) {Serial.println(Led+"on") ; digitalWrite (conduit [i], HIGH); valeur [i] = "off";} d’autre if(inString.indexOf(Led+"=off") > 0 || inString.indexOf("all=off") > 0) {Serial.println(Led+"on") ; digitalWrite (conduit [i], LOW); valeur [i] = "on";} client.println ("
« + Led + » ");} client.println("
Tous les ") ; client.println("
"); rupture ; {Si (c == '\n') {/ / nous commençons une nouvelle current_line_is_blank de ligne = true;} ElseIf (c! = '\r') {/ / nous avons obtenu un personnage sur le current_line_is_blank de ligne actuel = false;}} } / / donner le temps de navigateur web pour recevoir les delay(1) de données ; inString = "" ; client.Stop() ; } }
///////////////////////////////////////////////////////////////////////////////////////////////////////
l je vais télécharger ce code pour nous
(첨부파일을 확인해주세요)
exemple (온도센서)
#include
DHT11 dht11(2) ;
void setup()
{
Serial.Begin(9600) ;
}
void loop()
{
int err ;
temp de flotteur, humi ;
Si ((err=dht11.read (humi, temp)) == 0)
{
Serial.Print("Temperature:") ;
Serial.Print(temp) ;
}
d’autre
{
}
Delay(DHT11_RETRY_DELAY) ;
if(Temp > 35.5)
{
pinMode (13, HIGH) ;
}
d’autre
{
pinMode (13, faible) ;
}
}