forked from community/product-iots
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
1.6 KiB
78 lines
1.6 KiB
10 years ago
|
#include "SenseBotWifiAgent.h"
|
||
|
#include <Adafruit_CC3000.h>
|
||
|
#include <SPI.h>
|
||
10 years ago
|
#include <avr/wdt.h>
|
||
10 years ago
|
#include "dht.h"
|
||
|
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
|
||
|
SPI_CLOCK_DIVIDER); // you can change this clock speed
|
||
|
|
||
10 years ago
|
Adafruit_CC3000_Client client;
|
||
10 years ago
|
Adafruit_CC3000_Server httpServer(LISTEN_PORT);
|
||
|
|
||
|
uint32_t sserver;
|
||
|
dht DHT;
|
||
|
|
||
10 years ago
|
void setup()
|
||
|
{
|
||
|
if(CON_DEBUG) Serial.begin(9600);
|
||
|
|
||
|
pinMode(PIR_PIN, INPUT);
|
||
|
pinMode(LDR_PIN, INPUT);
|
||
|
pinMode(TEMP_PIN, INPUT);
|
||
|
for(int i = 0; i < 2; i++){
|
||
|
pinMode(motor_left[i], OUTPUT);
|
||
|
pinMode(motor_right[i], OUTPUT);
|
||
10 years ago
|
}
|
||
10 years ago
|
|
||
|
pinMode(enA, OUTPUT);
|
||
|
pinMode(enB, OUTPUT);
|
||
|
digitalWrite(enA, 100);
|
||
|
digitalWrite(enB, 100);
|
||
|
motor_stop();
|
||
10 years ago
|
|
||
10 years ago
|
do{
|
||
|
connectHttp();
|
||
|
}while( !cc3000.checkConnected() );
|
||
|
|
||
|
setupResource();
|
||
|
httpServer.begin();
|
||
|
wdt_enable(WDTO_8S);
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
void loop()
|
||
|
{
|
||
|
while( !cc3000.checkConnected() ){
|
||
|
connectHttp();
|
||
|
|
||
|
}
|
||
|
|
||
|
if(millis() - pollTimestamp > TURN_DELAY){
|
||
|
wdt_reset();
|
||
|
readControls();
|
||
|
drive();
|
||
|
pollTimestamp = millis();
|
||
|
|
||
|
}
|
||
|
//Serial.println(F("looping"));
|
||
|
getTemperature();
|
||
|
pir =digitalRead(PIR_PIN);
|
||
|
getSonar();
|
||
|
ldr =analogRead(LDR_PIN);
|
||
|
|
||
|
if(millis() - pushTimestamp > PUSH_INTERVAL){
|
||
|
wdt_reset();
|
||
|
while (!client.connected()) {
|
||
|
setupClient();
|
||
|
}
|
||
|
pushData();
|
||
|
// Serial.print("looping");
|
||
|
pushTimestamp = millis();
|
||
|
}
|
||
10 years ago
|
|
||
10 years ago
|
wdt_reset();
|
||
10 years ago
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|