完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
你好!我制作了这个简单的草图,以使用 Wemos D1 mini 在 DOT Matrix 上显示一些文本。一切正常,除了当我断开电源并重新连接时,它似乎像正常一样运行草图,但没有显示任何内容。
任何帮助,将不胜感激。我把所有东西都放在一个拧在一起的小盒子里,这样我就无法从盒子外面够到重置按钮…… 这是代码: 代码:全选// Libraries included #include #include #include #include "Arduino.h" #include #include #include "JsonStreamingParser.h" #include #include "InstagramStats.h" #include #include "theSwedishMaker.h" const uint16_t WAIT_tiME = 6000; //Time between fecthing data. // Define the typ of hardware and the pins used. #define HARDWARE_TYPE MD_MAX72XX::FC16_HW #define MAX_DEVICES 4 #define CLK_PIN 12 #define DATA_PIN 15 #define CS_PIN 13 // Hardware SPI connection //MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES); // Arbitrary output pins MD_Parola P = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES); #define API_KEY "********" //Your Youtube API-Key #define CHANNEL_ID "Youtube Channel ID" // Your youtube channel ID. String userName = "TheSwedishMaker"; // Your Instagram Username WiFiClientSecure client; //For ESP8266 boards InstagramStats instaStats(client); YoutubeApi api(API_KEY, client); // ======================================================================= // Configuration of router settings // ======================================================================= const char* ssid = "NETWORKNAME"; // SSID of local network const char* password = "*******"; // Password on network void setup() { P.begin(); P.setFont(fontSubs); // Connecting to wifi Serial.begin(115200); Serial.print("Connecting WiFi "); WiFi.begin(ssid, password); P.print(" WiFi..."); while (WiFi.status() != WL_CONNECTED) { Serial.print("."); delay(500); } Serial.println(""); Serial.print("Connected: "); Serial.println(WiFi.localIP()); client.setInsecure(); } void loop(void) { Serial.println("Getting data ..."); P.print("fetching"); int cnt = 0; //int yt1; long yt1,yt2,insta; while(1) { if(!cnt--) { cnt = 50; if(api.getChannelStatistics(CHANNEL_ID)) yt1 = api.channelStats.subscriberCount; yt2 = api.channelStats.viewCount; InstagramUserStats response = instaStats.getUserStats(userName); insta = response.followedByCount; } // FORMATO String subsCount = num_format(yt1); String viewCount = num_format(yt2); String instaFollowers = num_format(insta); Serial.println(subsCount); P.print("*" + subsCount); delay(3500); // P.print("*" + viewCount); //Uncomment if your want to show viewcount. // delay(3500); //Uncomment if you want to show viewcount. P.print("&" + instaFollowers); delay(5000); }} String num_format(long num){ String num_s; long num_original = num; if (num>99999 && num<=999999){ num = num / 1000; long fraction = num_original%1000; String num_fraction = String(fraction); String decimal = num_fraction.substring(0,1); num_s = String(num) + "." + decimal + "K"; } else if(num>999999){ num = num / 1000000; long fraction = num_original%1000000; String num_fraction = String(fraction); String decimal = num_fraction.substring(0,1); if (num_original<100000000){ num_s = " " + String(num) + "." + decimal + "M"; } else{ num_s = String(num) + "." + decimal + "M"; } } else{ int num_l = String(num).length(); char num_f[15]; int blankDigits = 6 - num_l; for(int i = 0; i < blankDigits; i++){ num_f = ' '; } num_f[blankDigits] = '\0'; num_s = num_f + String(num); } return num_s; } |
|
相关推荐
|
|
只有小组成员才能发言,加入小组>>
523浏览 6评论
433浏览 5评论
有没有办法在不使用混杂模式的情况下实现Wifi驱动程序接收缓冲区访问中断呢?
421浏览 5评论
413浏览 4评论
387浏览 4评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-1 12:27 , Processed in 0.699107 second(s), Total 76, Slave 59 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号