1616
1717// FirebaseNeoPixel is a sample that demonstrates how
1818// to set pixel data from Firebase.
19- #include < Firebase .h>
19+ #include < FirebaseArduino .h>
2020#include < ESP8266WiFi.h>
2121
2222#include < Adafruit_NeoPixel.h>
23- #include " colors_ext.h"
2423
2524// Set these to run example.
2625#define FIREBASE_HOST " example.firebaseio.com"
3130const int PIN=13 ;
3231Adafruit_NeoPixel strip = Adafruit_NeoPixel(32 , PIN, NEO_GRB + NEO_KHZ800);
3332
34- // TODO: Replace with your own credentials and keep these safe.
35- Firebase fbase =Firebase(FIREBASE_HOST, FIREBASE_AUTH );
33+ const int pixelPin = 13 ;
34+ Adafruit_NeoPixel strip =Adafruit_NeoPixel( 32 , pixelPin, NEO_GRB + NEO_KHZ800 );
3635
3736void setup () {
3837 Serial.begin (9600 );
@@ -41,56 +40,35 @@ void setup() {
4140 strip.setBrightness (25 );// 0 ... 255
4241 strip.show ();// Initialize all pixels to 'off'
4342
44- // Not connected, set the LEDs red
45- colorWipe (&strip,0xFF0000 ,50 );
46-
4743// connect to wifi.
4844 WiFi.begin (WIFI_SSID, WIFI_PASSWORD);
4945 Serial.print (" connecting" );
50-
51- int count =0 ;
5246while (WiFi.status () != WL_CONNECTED) {
53- // Draw rainbows while connecting
5447 Serial.print (" ." );
55- if (count < strip.numPixels ()){
56- strip.setPixelColor (count++,Wheel (&strip, count *8 ));
57- strip.show ();
58- }
59- delay (20 );
48+ delay (500 );
6049 }
6150 Serial.println ();
6251 Serial.print (" connected:" );
6352 Serial.println (WiFi.localIP ());
6453
65- // Connected, set the LEDs green
66- colorWipe (&strip,0x00FF00 ,50 );
54+ Firebase.begin (" example.firebaseio.com" ," secret_or_token" );
6755}
6856
6957
7058void loop () {
7159// Get all entries.
7260// TODO: Replace with streaming
73- FirebaseGet get =fbase .get (" /rgbdata" );
74- if (get. error ()) {
61+ FirebaseObject pixels =Firebase .get (" /rgbdata" );
62+ if (Firebase. failed ()) {
7563 Serial.println (" Firebase get failed" );
76- Serial.println (get .error (). message ());
64+ Serial.println (Firebase .error ());
7765return ;
7866 }
7967
80- // create an empty object
81- const JsonObject& pixelJSON = get.json ();
82-
83- if (pixelJSON.success ()){
84- for (int i=0 ; i < strip.numPixels (); i++) {
85- String pixelAddress =" pixel" +String (i);
86- String pixelVal = pixelJSON[pixelAddress];
87- Serial.println (pixelVal);
88- strip.setPixelColor (i, pixelVal.toInt ());
89- }
90- strip.show ();
91- }else {
92- Serial.println (" Parse fail." );
93- Serial.println (get.response ());
68+ for (int i =0 ; i < strip.numPixels (); i++) {
69+ int pixel = pixels.getInt (" pixel" + i);
70+ Serial.println (pixel);
71+ strip.setPixelColor (i, pixel);
9472 }
73+ strip.show ();
9574}
96-