|
22 | 22 | #include<Adafruit_NeoPixel.h> |
23 | 23 | #include"colors_ext.h" |
24 | 24 |
|
25 | | -constint PIN=13; |
26 | | -Adafruit_NeoPixel strip = Adafruit_NeoPixel(32, PIN, NEO_GRB + NEO_KHZ800); |
27 | | - |
28 | 25 | // Set these to run example. |
29 | 26 | #defineFIREBASE_HOST"example.firebaseio.com" |
30 | 27 | #defineFIREBASE_AUTH"token_or_secret" |
31 | 28 | #defineWIFI_SSID"SSID" |
32 | 29 | #defineWIFI_PASSWORD"PASSWORD" |
33 | 30 |
|
| 31 | +constint PIN=13; |
| 32 | +Adafruit_NeoPixel strip = Adafruit_NeoPixel(32, PIN, NEO_GRB + NEO_KHZ800); |
| 33 | + |
| 34 | +// TODO: Replace with your own credentials and keep these safe. |
34 | 35 | Firebase fbase = Firebase(FIREBASE_HOST, FIREBASE_AUTH); |
35 | 36 |
|
36 | | -voidConnectWifi(const String& ssid,const String& password ="") { |
37 | | -if (password !="") { |
38 | | - WiFi.begin(ssid, password); |
39 | | - }else { |
40 | | - WiFi.begin(ssid); |
41 | | - } |
| 37 | +voidsetup() { |
| 38 | + Serial.begin(9600); |
42 | 39 |
|
| 40 | + strip.begin(); |
| 41 | + strip.setBrightness(25);// 0 ... 255 |
| 42 | + strip.show();// Initialize all pixels to 'off' |
| 43 | + |
| 44 | +// Not connected, set the LEDs red |
| 45 | +colorWipe(&strip,0xFF0000,50); |
| 46 | + |
| 47 | +// connect to wifi. |
| 48 | + WiFi.begin(WIFI_SSID, WIFI_PASSWORD); |
43 | 49 | Serial.print("connecting"); |
| 50 | + |
| 51 | +int count =0; |
44 | 52 | while (WiFi.status() != WL_CONNECTED) { |
| 53 | +// Draw rainbows while connecting |
45 | 54 | Serial.print("."); |
46 | | -delay(500); |
| 55 | +if (count < strip.numPixels()){ |
| 56 | + strip.setPixelColor(count++,Wheel(&strip, count *8)); |
| 57 | + strip.show(); |
| 58 | + } |
| 59 | +delay(20); |
47 | 60 | } |
48 | 61 | Serial.println(); |
49 | 62 | Serial.print("connected:"); |
50 | 63 | Serial.println(WiFi.localIP()); |
51 | | -} |
52 | | - |
53 | | -voidsetup() { |
54 | | - Serial.begin(9600); |
55 | | -ConnectWifi(WIFI_SSID, WIFI_PASSWORD); |
56 | | - |
57 | | - strip.begin(); |
58 | | - strip.setBrightness(25);// 0 ... 255 |
59 | | - strip.show();// Initialize all pixels to 'off' |
60 | 64 |
|
61 | 65 | // Connected, set the LEDs green |
62 | 66 | colorWipe(&strip,0x00FF00,50); |
|