Hardware components | ||||||
| × | 1 | ||||
| × | 1 | ||||
Hand tools and fabrication machines | ||||||
|
I bought a very nice transparent display from DF Robot, and I will use it to build my new project.
The idea is to mount the display on plexiglass.
So I cut two pieces. The first to use it as a base, while the second to squeeze the display inside.
Then I had to model with hot air the base part of the plexiglass. I used a heater at 165 degrees. You can also go higher and melt the plastic quicker, but the risk is that it breaks. So take your time and go slow.
The video will show you how I heated the plexiglass. You need to heat it all over the side that you want to melt. It takes time but at the end, the plastic start to bend in the correct way.
At the end, you can see the result. It's not perfect, but it's OK for the project needs. Remember, this is just for fun.
After, I mounted the display with two screws and I tested that the display was working. I had to connect all the wiring on my Arduino. Please look at the diagram if you wish to make your own version.
At the end, I loaded the software version I coded for the project. It's a clock that shows: Date. Day of Week. Time of the day. Seconds remaining before the end of year. Seconds remaining before the end of the month. Seconds remaining before the end of the day.
// Sketch clock with Arduino and DF Robot Transparent Display
// Carlo Stramaglia
// 26 March 2022
// Youtube channel https://www.youtube.com/c/CarloStramaglia
#include <Arduino.h>
#include <U8g2lib.h>
#include <WiFiNINA.h>
#include <UnixTime.h>
#include "arduino_secrets.h"
#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif
UnixTime tm (1);
int Year;
int Month;
int Day;
int Hour;
int Minute;
int Second;
int Status=0;
long SecondsToEnd;
U8G2_SSD1309_128X64_NONAME0_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 5, /* dc=*/ 7, /* reset=*/ 6);
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
char ssid[] = SECRET_SSID; // your network SSID (name)
char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0; // your network key index number (needed only for WEP)
int status = WL_IDLE_STATUS;
void printWifiStatus()
{
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your board's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("Signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
}
void setup() {
Serial.begin(115200);
u8g2.begin();
WiFi.begin(SECRET_SSID, SECRET_PASS);
delay(1000);
// attempt to connect to Wifi network:
while (status != WL_CONNECTED)
{
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.status();
delay(1000);
}
printWifiStatus();
}
void loop() {
int i;
for (i=0; i< 20; i++)
display();
for (i=0; i< 20; i++)
secondsToYear();
for (i=0; i< 20; i++)
secondsToMonth();
for (i=0; i< 20; i++)
secondsToDay();
}
//Display second to end of day
void secondsToDay()
{
char buf[40];
tm.getDateTime (WiFi.getTime());
Day = tm.day;
Month = tm.month;
Year = tm.year;
Hour = tm.hour;
Minute = tm.minute;
Second = tm.second;
SecondsToEnd = (long)(23-Hour)*60*60;
SecondsToEnd = SecondsToEnd + (long)(59-Minute)*60;
SecondsToEnd = SecondsToEnd + (long)60-Second;
Serial.print ("Time: ");
Serial.print (Hour);
Serial.print (Minute);
Serial.println (Second);
Serial.print ("Seconds to end of day: ");
sprintf(buf, "%.8ld", SecondsToEnd);
Serial.println (buf);
u8g2.clearBuffer();
u8g2.setFont(u8g2_font_ncenB18_tr);
u8g2.drawStr(5,50, buf);
sprintf(buf, "Seconds To Day End");
u8g2.setFont(u8g2_font_ncenB08_tr);
u8g2.drawStr(1,10, buf);
u8g2.sendBuffer();
delay(1000);
}
// Display Seconds to end of the month
void secondsToMonth()
{
char buf[40];
tm.getDateTime (WiFi.getTime());
Day = tm.day;
Month = tm.month;
Year = tm.year;
Hour = tm.hour;
Minute = tm.minute;
Second = tm.second;
if (Month == 1 or Month == 3 or Month == 5 or Month == 7 or Month == 8 or Month == 10 or Month == 12)
{
Serial.print ("Days to end of month: ");
Serial.println (31-Day);
if (Day != 31)
{
SecondsToEnd = (long)(31-Day)*24*60*60;
SecondsToEnd = SecondsToEnd + (long)(23-Hour)*60*60;
}
else
SecondsToEnd = (long)(23-Hour)*60*60;
SecondsToEnd = SecondsToEnd + (long)(59-Minute)*60;
SecondsToEnd = SecondsToEnd + (long)60-Second;
}
else if (Month == 2)
{
Serial.print ("Days to end of month: ");
Serial.println (27-Day);
if (Day != 28)
{
SecondsToEnd = (long)(27-Day)*24*60*60;
SecondsToEnd = SecondsToEnd + (long)(23-Hour)*60*60;
}
else
SecondsToEnd = (long)(23-Hour)*60*60;
SecondsToEnd = SecondsToEnd + (long)(59-Minute)*60;
SecondsToEnd = SecondsToEnd + (long)60-Second;
}
else if (Month == 4 or Month == 6 or Month == 9 or Month == 11)
{
Serial.print ("Days to end of month: ");
Serial.println (29-Day);
if (Day !=30)
{
SecondsToEnd = (long)(29-Day)*24*60*60;
SecondsToEnd = SecondsToEnd + (long)(23-Hour)*60*60;
}
else
SecondsToEnd = (long)(23-Hour)*60*60;
SecondsToEnd = SecondsToEnd + (long)(59-Minute)*60;
SecondsToEnd = SecondsToEnd + (long)60-Second;
}
Serial.print ("Time: ");
Serial.print (Hour);
Serial.print (Minute);
Serial.println (Second);
Serial.print ("Seconds to end of month: ");
sprintf(buf, "%.8ld", SecondsToEnd);
Serial.println (buf);
u8g2.clearBuffer();
u8g2.setFont(u8g2_font_ncenB18_tr);
u8g2.drawStr(5,50, buf);
sprintf(buf, "Seconds To Month End");
u8g2.setFont(u8g2_font_ncenB08_tr);
u8g2.drawStr(0,10, buf);
u8g2.sendBuffer();
delay(1000);
}
// Display Seconds to end of the year
void secondsToYear()
{
char buf[40];
tm.getDateTime (WiFi.getTime());
Day = tm.day;
Month = tm.month;
Year = tm.year;
Hour = tm.hour;
Minute = tm.minute;
Second = tm.second;
if (Month == 1)
{
Serial.print ("Days to end of month: ");
Serial.println (31-Day);
if (Day != 31)
{
SecondsToEnd = (long)(31-Day)*24*60*60; //da aggiungere
SecondsToEnd = SecondsToEnd + (long)28*24*60*60;
}
else
SecondsToEnd = (long)28*24*60*60;
SecondsToEnd = SecondsToEnd + (long)6*31*24*60*60;
SecondsToEnd = SecondsToEnd + (long)4*30*24*60*60;
SecondsToEnd = SecondsToEnd + (long)(23-Hour)*60*60;
SecondsToEnd = SecondsToEnd + (long)(59-Minute)*60;
SecondsToEnd = SecondsToEnd + (long)60-Second;
}
else if (Month == 2)
{
Serial.print ("Days to end of month: ");
Serial.println (27-Day);
if (Day != 28)
{
SecondsToEnd = (long)(27-Day)*24*60*60;
SecondsToEnd = SecondsToEnd + (long)6*31*24*60*60;
}
else
SecondsToEnd = (long)6*31*24*60*60;
SecondsToEnd = SecondsToEnd + (long)4*30*24*60*60;
SecondsToEnd = SecondsToEnd + (long)(23-Hour)*60*60;
SecondsToEnd = SecondsToEnd + (long)(59-Minute)*60;
SecondsToEnd = SecondsToEnd + (long)60-Second;
}
else if (Month == 3)
{
Serial.print ("Days to end of month: ");
Serial.println (30-Day);
if (Day != 31)
{
SecondsToEnd = (long)(30-Day)*24*60*60;
SecondsToEnd = SecondsToEnd + (long)5*31*24*60*60;
}
else
SecondsToEnd = (long)5*31*24*60*60;
SecondsToEnd = SecondsToEnd + (long)4*30*24*60*60;
SecondsToEnd = SecondsToEnd + (long)(23-Hour)*60*60;
SecondsToEnd = SecondsToEnd + (long)(59-Minute)*60;
SecondsToEnd = SecondsToEnd + (long)60-Second;
}
else if (Month == 4)
{
Serial.print ("Days to end of month: ");
Serial.println (29-Day);
if (Day != 30)
{
SecondsToEnd = (long)(24-Day)*24*60*60;
SecondsToEnd = SecondsToEnd + (long)5*31*24*60*60;
}
else
SecondsToEnd = (long)5*31*24*60*60;
SecondsToEnd = SecondsToEnd + (long)3*30*24*60*60;
SecondsToEnd = SecondsToEnd + (long)(23-Hour)*60*60;
SecondsToEnd = SecondsToEnd + (long)(59-Minute)*60;
SecondsToEnd = SecondsToEnd + (long)60-Second;
}
else if (Month == 5)
{
Serial.print ("Days to end of month: ");
Serial.println (30-Day);
if (Day != 31)
{
SecondsToEnd = (long)(30-Day)*24*60*60;
SecondsToEnd = SecondsToEnd + (long)4*31*24*60*60;
}
else
SecondsToEnd = (long)4*31*24*60*60;
SecondsToEnd = SecondsToEnd + (long)3*30*24*60*60;
SecondsToEnd = SecondsToEnd + (long)(23-Hour)*60*60;
SecondsToEnd = SecondsToEnd + (long)(59-Minute)*60;
SecondsToEnd = SecondsToEnd + (long)60-Second;
}
else if (Month == 6)
{
Serial.print ("Days to end of month: ");
Serial.println (29-Day);
if (Day !=30)
{
SecondsToEnd = (long)(29-Day)*24*60*60;
SecondsToEnd = SecondsToEnd + (long)4*31*24*60*60;
}
else
SecondsToEnd = (long)4*31*24*60*60;
SecondsToEnd = SecondsToEnd + (long)2*30*24*60*60;
SecondsToEnd = SecondsToEnd + (long)(23-Hour)*60*60;
SecondsToEnd = SecondsToEnd + (long)(59-Minute)*60;
SecondsToEnd = SecondsToEnd + (long)60-Second;
}
else if (Month == 7)
{
Serial.print ("Days to end of month: ");
Serial.println (30-Day);
if (Day != 31)
{
SecondsToEnd = (long)(30-Day)*24*60*60;
SecondsToEnd = SecondsToEnd + (long)3*31*24*60*60;
}
else
SecondsToEnd = (long)3*31*24*60*60;
SecondsToEnd = SecondsToEnd + (long)2*30*24*60*60;
SecondsToEnd = SecondsToEnd + (long)(23-Hour)*60*60;
SecondsToEnd = SecondsToEnd + (long)(59-Minute)*60;
SecondsToEnd = SecondsToEnd + (long)60-Second;
}
else if (Month == 8)
{
Serial.print ("Days to end of month: ");
Serial.println (30-Day);
if (Day != 31)
{
SecondsToEnd = (long)(30-Day)*24*60*60;
SecondsToEnd = SecondsToEnd + (long)2*31*24*60*60;
}
else
SecondsToEnd = (long)2*31*24*60*60;
SecondsToEnd = SecondsToEnd + (long)2*30*24*60*60;
SecondsToEnd = SecondsToEnd + (long)(23-Hour)*60*60;
SecondsToEnd = SecondsToEnd + (long)(59-Minute)*60;
SecondsToEnd = SecondsToEnd + (long)60-Second;
}
else if (Month == 9)
{
Serial.print ("Days to end of month: ");
Serial.println (29-Day);
if (Day != 30)
{
SecondsToEnd = (long)(29-Day)*24*60*60;
SecondsToEnd = SecondsToEnd + (long)2*31*24*60*60;
}
else
SecondsToEnd = (long)2*31*24*60*60;
SecondsToEnd = SecondsToEnd + (long)1*30*24*60*60;
SecondsToEnd = SecondsToEnd + (long)(23-Hour)*60*60;
SecondsToEnd = SecondsToEnd + (long)(59-Minute)*60;
SecondsToEnd = SecondsToEnd + (long)60-Second;
}
else if (Month == 10)
{
Serial.print ("Days to end of month: ");
Serial.println (30-Day);
if (Day != 31)
{
SecondsToEnd = (long)(30-Day)*24*60*60;
SecondsToEnd = SecondsToEnd + (long)1*31*24*60*60;
}
else
SecondsToEnd = (long)1*31*24*60*60;
SecondsToEnd = SecondsToEnd + (long)1*30*24*60*60;
SecondsToEnd = SecondsToEnd + (long)(23-Hour)*60*60;
SecondsToEnd = SecondsToEnd + (long)(59-Minute)*60;
SecondsToEnd = SecondsToEnd + (long)60-Second;
}
else if (Month == 11)
{
Serial.print ("Days to end of month: ");
Serial.println (29-Day);
if (Day != 30)
{
SecondsToEnd = (long)(29-Day)*24*60*60;
SecondsToEnd = SecondsToEnd + (long)1*31*24*60*60;
}
else
SecondsToEnd = (long)1*31*24*60*60;
SecondsToEnd = SecondsToEnd + (long)(23-Hour)*60*60;
SecondsToEnd = SecondsToEnd + (long)(59-Minute)*60;
SecondsToEnd = SecondsToEnd + (long)60-Second;
}
else if (Month == 12)
{
Serial.print ("Days to end of month: ");
Serial.println (30-Day);
if (Day != 31)
{
SecondsToEnd = (long)(30-Day)*24*60*60;
SecondsToEnd = SecondsToEnd + (long)(23-Hour)*60*60;
}
else
SecondsToEnd = (long)(23-Hour)*60*60;
SecondsToEnd = SecondsToEnd + (long)(59-Minute)*60;
SecondsToEnd = SecondsToEnd + (long)60-Second;
}
Serial.print ("Months to end of year: ");
Serial.println (12-Month);
Serial.print ("Year now: ");
Serial.println (tm.year);
Serial.print ("Time: ");
Serial.print (Hour);
Serial.print (Minute);
Serial.println (Second);
Serial.print ("Seconds to end of year: ");
sprintf(buf, "%.8ld", SecondsToEnd);
Serial.println (buf);
u8g2.clearBuffer();
u8g2.setFont(u8g2_font_ncenB18_tr);
u8g2.drawStr(5,50, buf);
sprintf(buf, "Seconds To Year End");
u8g2.setFont(u8g2_font_ncenB08_tr);
u8g2.drawStr(0,10, buf);
u8g2.sendBuffer();
delay(1000);
}
// Display Ora a data
void display()
{
char buf[40];
char monthWord[40];
tm.getDateTime (WiFi.getTime());
u8g2.clearBuffer();
u8g2.setFont(u8g2_font_ncenB08_tr);
switch (tm.month)
{
case 1:
sprintf(monthWord,"January");
break;
case 2:
sprintf(monthWord,"February");
break;
case 3:
sprintf(monthWord,"March");
break;
case 4:
sprintf(monthWord,"April");
break;
case 5:
sprintf(monthWord,"May");
break;
case 6:
sprintf(monthWord,"June");
break;
case 7:
sprintf(monthWord,"July");
break;
case 8:
sprintf(monthWord,"August");
break;
case 9:
sprintf(monthWord,"September");
break;
case 10:
sprintf(monthWord,"October");
break;
case 11:
sprintf(monthWord,"November");
break;
case 12:
sprintf(monthWord,"December");
break;
default:
sprintf(monthWord,"Unknown");
break;
}
sprintf(buf, "%.2d %s %d", tm.day, monthWord, tm.year);
Serial.print ("Date: ");
Serial.println(buf);
u8g2.drawStr(20,10, buf);
switch (tm.dayOfWeek)
{
case 1:
sprintf(buf,"Monday");
break;
case 2:
sprintf(buf,"Tuesday");
break;
case 3:
sprintf(buf,"Wednesday");
break;
case 4:
sprintf(buf,"Thursday");
break;
case 5:
sprintf(buf,"Friday");
break;
case 6:
sprintf(buf,"Saturday");
break;
case 7:
sprintf(buf,"Sunday");
break;
default:
sprintf(buf,"Unknown");
break;
}
Serial.print ("Day of Week: ");
Serial.println(buf);
u8g2.drawStr(35,30, buf);
sprintf(buf, "%.2d:%.2d:%.2d", tm.hour, tm.minute, tm.second);
Serial.print ("Time: ");
Serial.println(buf);
u8g2.drawStr(35,50, buf);
u8g2.sendBuffer();
delay(1000);
}
Comments