|
simpleTry.zip
(28.08 KB, 下载次数: 105)
- <P> /*****************************************</P>
- <P>Name: Gizwits + ArduinoUnoWiFi Library
- Author: <A href="mailto:tli@gizwits.com">tli@gizwits.com</A> / <A href="mailto:bing@arduino.org.cn">bing@arduino.org.cn</A>
- Version: V1.0
- Init: 2016-12-23
- Modify: 2016-12-23
- *******************************************/</P>
- <P>//只有一个buer开关数据点
- #include "Gizwits.h"
- #include <Wire.h></P>
- <P>Gizwits myGizwits;</P>
- <P>void setup() {
- // put your setup code here, to run once:</P>
- <P> Serial.begin(9600);
- pinMode(7,INPUT_PULLUP);
- pinMode(8,INPUT_PULLUP);
- pinMode(9,INPUT_PULLUP);
- digitalWrite(9,HIGH);//9号数字接口连接led灯 测试是否接收到数据
- delay(500);
- digitalWrite(9,LOW);
- delay(500);
- digitalWrite(9,HIGH);
- delay(500);
- digitalWrite(9,LOW);
- myGizwits.begin();
- }</P>
- <P>void loop() {
-
- //Configure network
- //if(XXX) //Trigger Condition
- //myGizwits.setBindMode(0x02); //0x01:Enter AP Mode;0x02:Enter Airlink Mode
- /*
- bool varR_buer = 0;
- if(myGizwits.hasBeenSet(EVENT_BUER))
- {
- myGizwits.read(EVENT_BUER,&varR_buer);//Address for storing data
- }
- //binary datapoint handle
- */
- //Configure network
- if(digitalRead(7) == LOW) //Trigger Condition
- {
- delay(10);
- while(digitalRead(7) == LOW);
- myGizwits.setBindMode(WIFI_AIRLINK_MODE); //0x01:Enter AP Mode;0x02:Enter Airlink Mode
- // Serial.println("START_AIRLINK");
- }</P>
- <P>
- if(digitalRead(8) == LOW) //Trigger Condition
- {
- delay(10);
- while(digitalRead(8) == LOW);
- myGizwits.setBindMode(WIFI_RESET_MODE); //0x01:Enter AP Mode;0x02:Enter Airlink Mode
- //Serial.println("START_RESET");
- }</P>
- <P>
- if(myGizwits.wifiHasBeenSet(WIFI_CON_ROUTER))
- {
- digitalWrite(8,LOW);
- //Serial.println("Success_con_Router");
- }
- else if(myGizwits.wifiHasBeenSet(WIFI_AIRLINK))
- {
- digitalWrite(8,HIGH);
- //Serial.println("IN_AIR_LINK");
- }
- bool varR_buer = 0;
- if(myGizwits.hasBeenSet(EVENT_BUER))
- {
- myGizwits.read(EVENT_BUER,&varR_buer);//Address for storing data
- digitalWrite(9,HIGH);//9号数字接口连接led灯 测试是否接收到数据
- //测试发现 没有数据
- delay(500);
- digitalWrite(9,LOW);
- delay(500);
- if(varR_buer == 1)
- {
- // //测试发现 没有数据
- digitalWrite(9,HIGH);
- delay(100);
- digitalWrite(9,LOW);
- delay(100);
- digitalWrite(9,HIGH);
- delay(100);
- digitalWrite(9,LOW);
- digitalWrite(9,HIGH);
- delay(100);
- digitalWrite(9,LOW);
- delay(100);
- digitalWrite(9,HIGH);
- delay(100);
- digitalWrite(9,LOW); digitalWrite(9,HIGH);
- delay(100);
- digitalWrite(9,LOW);
- delay(100);
- digitalWrite(9,HIGH);
- delay(100);
- digitalWrite(9,LOW);
- delay(100);
- }
- else
- {
- //Serial.println("LED_OFF");
-
- }
- }
- myGizwits.process();
- }</P>
复制代码
|
|