TESTPAGE

出自YFRobotwiki
在2020年4月8日 (三) 15:08由Allblue對話 | 貢獻所做的修訂版本

跳轉到: 導覽搜尋
  1. /*
  2.   8-segment display driver of YFRobot 4-bit digital tube module based on TM1650 chip
  3.   Created by yfrobot,Released into the public domain.
  4. */
  5.  
  6. #include <YFTM1650.h>
  7.  
  8. YFTM1650 YF_4BitDis(10, 11);
  9.  
  10. void setup()
  11. {
  12.   Serial.begin(38400); //Start serial communication at 9600 for debug statements
  13.   Serial.println("YFRobot TM1650 Example Code");
  14.   YF_4BitDis.init();
  15. }
  16.  
  17. void loop()
  18. {
  19.   YF_4BitDis.setBrightness(1);
  20.   YF_4BitDis.displayString(String("____"));
  21.   delay(1000);
  22.   char line[] = "1234";
  23.  
  24.   YF_4BitDis.displayString(line);
  25.   YF_4BitDis.setBrightness(7);
  26.  
  27.   for (int i = 1; i <= 8; i++) {
  28.     YF_4BitDis.setBrightness(i);
  29.     delay(200);
  30.   }
  31.   for (int i = 1; i <= 8; i++) {
  32.     YF_4BitDis.setBrightness(8 - i);
  33.     delay(200);
  34.   }
  35.  
  36.   YF_4BitDis.displayString(-1.235);
  37.   delay(1000);
  38.  
  39.   YF_4BitDis.displayString(12.10);
  40.   delay(1000);
  41.  
  42.   YF_4BitDis.displayString(String("abcd"));
  43.   delay(2000);
  44.  
  45.   YF_4BitDis.displayString(2020);
  46.   delay(2000);
  47.  
  48.   if (YF_4BitDis.displayRunning(String("1234567890abcdefghijklmnop"))) {
  49.     delay(500);
  50.     while (YF_4BitDis.displayRunningShift()) {
  51.       delay(500);
  52.     }
  53.   }
  54.   delay(2000);
  55.  
  56.   for (int i = 0; i < 20; i++) {
  57.     YF_4BitDis.displayOff();
  58.     delay(200);
  59.     YF_4BitDis.displayOn();
  60.     delay(200);
  61.   }
  62.  
  63.   for (int i = 0; i < 20; i++) {
  64.     YF_4BitDis.setBrightness(1);
  65.     delay(200);
  66.     YF_4BitDis.setBrightness(8);
  67.     delay(200);
  68.   }
  69.  
  70.   for (int i = 0; i < 20; i++) {
  71.     for (int j = 0; j < 4; j++) {
  72.       YF_4BitDis.setDot(j, true);
  73.       delay(200);
  74.     }
  75.     for (int j = 0; j < 4; j++) {
  76.       YF_4BitDis.setDot(j, false);
  77.       delay(200);
  78.     }
  79.   }
  80. }

聯繫我們

YFROBOT網站:www.yfrobot.com

手機:17696701116(微信/QQ同號)

QQ群【YFROBOT電子技術愛好者】:243067479

郵件:finalvalue@yfrobot.com