Lixie是一个开放,现代的辉光管替代品!
Lixie是一个数字显示模块,利用现代手段模拟老式辉光管的显示效果,每个模块显示一位数字,配合Arduino开发板、Node MCU开发板或者树莓派等使用。
通常可以组合4个(或更多)用于时钟显示时间、温度等任何数字数值
它是如何工作的?
Lixie通过光线穿过透明烯酸的边缘照射在雕刻的部分,这使丙烯酸的平坦表面保持透明,只雕刻部分亮起来!现在把
标识着数字0-9的10块堆叠在一起,这样就可以清晰的分别显示每个数字!
它能做什么?
Lixie基于WS2812B LED是您可以想到的任何数字信息显示屏!时钟,温度、湿度,计数器等
如何使用?
不同于辉光管需要高压电,Lixie只需要5V即可点亮,设置和使用也是极其简单的。只需将5V和GND引脚连接到Arduino,并将“DIN”引脚连接到任何数字引脚。在编程时包含Lixie library即可
例如:
#include "Lixie.h" // Include Lixie Library
#define DATA_PIN 5
#define NUM_LIXIES 4
Lixie lix(DATA_PIN, NUM_LIXIES); // Set class name to "lix" and define your Lixie setup
uint16_t count = 0; // Use this number to count up
void setup() {
lix.begin(); // Initialize LEDs
}
void loop() {
lix.write(count); // Write the count to the displays
count++; // Increment count
delay(1000);
}
Lixie被设计为WS2812B条,这意味着您可以把更多的连接在一起,只要您的电源可以处理!每个电路板上有20个LED,但是通常情况下,在给定的时间只有两个LED同时亮起。
Lixie library还将所有的工作推送到一个整数的每个数字到显示,所以如果你有4个Lixies,调用lix.write(314)将显示“314”或“0314”!
什么使得LiXie不同?
低电压
虽然传统的Nixie Tube显示器采用了一个危险的170V电源,Lixie只运行5伏,使儿童,宠物和新兴的爱好者安全!连接器。
方便
Lixie基于WS2812B LED,这意味着它们不需要任何专门的驱动程序 - 只需一个微控制器!连接器。
可拓展
您可以简单地连接一个数字到下一个数字,并用Lixie Arduino库驱动它们!
软件 - Arduino C ++库
| [attachment=10662316][attachment=10662317][attachment=10662318]
|
由四个Lixie和NodeMCU组成的NTP时钟代码
[url=]复制代码[/url]
- #include "Lixie.h" // Include Lixie Library
- #define DATA_PIN 4
- #define NUM_LIXIES 4
- Lixie lix(DATA_PIN, NUM_LIXIES);
- #include
- #include
- #include
- #include // WifiMulti Lib for connection handling
- ESP8266WiFiMulti WiFiMulti;
- //---------------------------------------
- const char* WIFI_SSID = "xxxxxxxxx"; // your network SSID (name)
- const char* WIFI_PASS = "123456789"; // your network password
- const bool SIX_DIGIT = false; // True if 6-digit clock with seconds true or false
- const int TIME_OFFSET = +8; // Beijing Time GMT+8
- const byte TIME_COLOR_RGB[3] = {0,255,255}; // CYAN
- //---------------------------------------
- // NTP Servers:
- static const char ntpServerName[] = "s1a.time.edu.cn";
- //static const char ntpServerName[] = "s1b.time.edu.cn";
- //static const char ntpServerName[] = "time-a.timefreq.bldrdoc.gov";
- //static const char ntpServerName[] = "time-b.timefreq.bldrdoc.gov";
- //static const char ntpServerName[] = "time-c.timefreq.bldrdoc.gov";
- WiFiUDP Udp;
- unsigned int localPort = 8888; // local port to listen for UDP packets
- time_t getNtpTime();
- void digitalClockDisplay();
- void sendNTPpacket(IPAddress &address);
- void setup()
- {
- lix.begin(); // Initialize LEDs
- Serial.begin(115200);
- WiFiMulti.addAP(WIFI_SSID, WIFI_PASS); // Your WIFI credentials
- // This sets all lights to yellow while we're connecting to WIFI
- while ((WiFiMulti.run() != WL_CONNECTED)) {
- lix.color(255, 255, 0);
- lix.write(8888);
- delay(100);
- }
- // Green on connection success
- lix.color(0, 255, 0);
- lix.write(9999);
- delay(500);
- // Reset colors to default
- lix.color(255, 255, 255);
- lix.clear();
- Serial.print("IP number assigned by DHCP is ");
- Serial.println(WiFi.localIP());
- Serial.println("Starting UDP");
- Udp.begin(localPort);
- Serial.print("Local port: ");
- Serial.println(Udp.localPort());
- Serial.println("waiting for sync");
- setSyncProvider(getNtpTime);
- setSyncInterval(300);
- }
- time_t prevDisplay = 0; // when the digital clock was displayed
- void loop()
- {
- if (timeStatus() != timeNotSet) {
- if (now() != prevDisplay) { //update the display only if time has changed
- prevDisplay = now();
- digitalClockDisplay();
- }
- }
- }
- void digitalClockDisplay()
- {
- // digital clock display of the time
- String time_now;
- String h;
- String m;
- String s;
- if(hour() < 10){
- h = "0"+String(hour());
- }
- else{
- h = String(hour());
- }
- if(minute() < 10){
- m = "0"+String(minute());
- }
- else{
- m = String(minute());
- }
- if(second() < 10){
- s = "0"+String(second());
- }
- else{
- s = String(second());
- }
- time_now += h;
- time_now += ":";
- time_now += m;
- if(SIX_DIGIT == true){
- time_now += ":";
- time_now += s;
- }
- char buf[10];
- time_now.toCharArray(buf,10);
- lix.color(TIME_COLOR_RGB[0],TIME_COLOR_RGB[1],TIME_COLOR_RGB[2]);
- lix.write(buf);
- Serial.println(time_now);
- }
- /*-------- NTP code ----------*/
- const int NTP_PACKET_SIZE = 48; // NTP time is in the first 48 bytes of message
- byte packetBuffer[NTP_PACKET_SIZE]; //buffer to hold incoming & outgoing packets
- time_t getNtpTime()
- {
- IPAddress ntpServerIP; // NTP server's ip address
- while (Udp.parsePacket() > 0) ; // discard any previously received packets
- Serial.println("Transmit NTP Request");
- // get a random server from the pool
- WiFi.hostByName(ntpServerName, ntpServerIP);
- Serial.print(ntpServerName);
- Serial.print(": ");
- Serial.println(ntpServerIP);
- sendNTPpacket(ntpServerIP);
- uint32_t beginWait = millis();
- while (millis() - beginWait < 1500) {
- int size = Udp.parsePacket();
- if (size >= NTP_PACKET_SIZE) {
- Serial.println("Receive NTP Response");
- Udp.read(packetBuffer, NTP_PACKET_SIZE); // read packet into the buffer
- unsigned long secsSince1900;
- // convert four bytes starting at location 40 to a long integer
- secsSince1900 = (unsigned long)packetBuffer[40] << 24;
- secsSince1900 |= (unsigned long)packetBuffer[41] << 16;
- secsSince1900 |= (unsigned long)packetBuffer[42] << 8;
- secsSince1900 |= (unsigned long)packetBuffer[43];
- return secsSince1900 - 2208988800UL + TIME_OFFSET * SECS_PER_HOUR;
- }
- }
- Serial.println("No NTP Response :-(");
- return 0; // return 0 if unable to get the time
- }
- // send an NTP request to the time server at the given address
- void sendNTPpacket(IPAddress &address)
- {
- // set all bytes in the buffer to 0
- memset(packetBuffer, 0, NTP_PACKET_SIZE);
- // Initialize values needed to form NTP request
- // (see URL above for details on the packets)
- packetBuffer[0] = 0b11100011; // LI, Version, Mode
- packetBuffer[1] = 0; // Stratum, or type of clock
- packetBuffer[2] = 6; // Polling Interval
- packetBuffer[3] = 0xEC; // Peer Clock Precision
- // 8 bytes of zero for Root Delay & Root Dispersion
- packetBuffer[12] = 49;
- packetBuffer[13] = 0x4E;
- packetBuffer[14] = 49;
- packetBuffer[15] = 52;
- // all NTP fields have been given values, now
- // you can send a packet requesting a timestamp:
- Udp.beginPacket(address, 123); //NTP requests are to port 123
- Udp.write(packetBuffer, NTP_PACKET_SIZE);
- Udp.endPacket();
- }
|