Hi, i have some problem with my Arduino 101 and Shield YUN. I have to use the shield wifi to connect my Arduino to Blynk app. This is my code, but it doesn't work because Blynk says that the "device is offline". Can you help me? Thanks a lot!
#define BLYNK_PRINT Serial
#include <Ultrasonic.h>
#include <SPI.h>
#include <WiFi.h>
#include <BlynkSimpleWifi.h>
#include <CurieBLE.h>
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "SSID";
char pass[] = "PASS";
// Blynk token
char auth[] = "auth";
WidgetLED green(V1);
WidgetLED orange(V2);
WidgetLED red(V3);
WidgetMap myMap(V4);
BlynkTimer timer;
int distance = 0;
int thresh[3] = {25, 50, 75};
Ultrasonic ultrasonic(12, 13);
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
// If you want to remove all points:
//myMap.clear();
int index = 1;
float lat = 40.8185844;
float lon = 16.55683978;
myMap.location(index, lat, lon, "value");
}
void loop()
{
distance = ultrasonic.distanceRead();
Serial.println(distance);
Blynk.run();
if(distance<thresh[0])
green.on();
else if(distance<thresh[1]){
green.on();
orange.on();
}
else if(distance<thresh[2]){
green.on();
orange.on();
red.on();
}
else{
green.off();
orange.off();
red.off();
delay(100);
}
}