yt_link
insta_link
fb_link
twitter_link

Homemade NIXIEs
page 2/2


Homemade NIXIEs - DIY vintage clock

Help me by sharing this post



PART 4 - The code

Ok, now we have everything connected. Is time for the code. It is quite simple but a bit long. We have to inport the libraries for the DS3231 real time clock and define the SDA and SCL pins. We also define the pins for the CLK, DATA and CS for the MAX7219 driver. In this case those will be D2 D3 and D4. In the setup loop we start the RTC module and define the MAX7219 pins as outputs.


Downlaod full code here:




rtc.begin();                                  //We start the real time module
pinMode(MAX7219_Data_IN, OUTPUT);             //Define the data pin for the MAX7219 as output
pinMode(MAX7219_Chip_Select, OUTPUT);         //Define the cs pin for the MAX7219 as output
pinMode(MAX7219_Clock, OUTPUT);               //Define the clock pin for the MAX7219 as output
digitalWrite(MAX7219_Chip_Select, HIGH);      //We set the CS to high, CS is negative enabeled


Download the full code from above. Read all the comments in the code line by line to understand more. But the code dose this: We read the real time from the module using i2c communication. We pass the hour and minute from String to integer. Then we use then shift function to pass the numbers to the 7 segment displays and by that show the hour and minute. If the buttons are presed we increase the hour and minute by 1. Before, make sure you set the time to the RTC using the library example.

Below you ahve the config of thr 7 segment displays. Change those if you want to reduce or increase the brightness or any other settings. That's it. Compile, select Arduino NANO board, select the COM and uplaod the code. Now the clock should work and display time.


  shift(0x0f, 0x00); //display test register - test mode off
  shift(0x0c, 0x01); //shutdown register - normal operation
  shift(0x0b, 0x04); //scan limit register - display digits 0 thru 7
  shift(0x0a, 0x01); //intensity register - Min brightness: 0x01, Max brightness: 0x0f
  shift(0x09, 0xff); //decode mode register - CodeB decode all digits

  shift(0x01, 0xff); //Turn off all segments
  shift(0x02, 0xff); 
  shift(0x03, 0xff); 
  shift(0x04, 0xff);











Go back ←

Help me by sharing this post








ADVERTISERS
PCBWAY PCB service

PCBWAY PCB service

PCBWAY PCB service



Gearbest Alfawise U30 2.8 inch Touch Screen DIY Desktop 3D Printer - U30 EU Plug Black
Alfawise U30 2.8 inch Touch Screen DIY Desktop 3D Printer - U30 EU Plug Black only $$162.89

AFFILATE

Gearbest Creality3D CR - 10S 3D Printer - EU Plug Upgrade Version Coffee and Black
Creality3D CR - 10S 3D Printer - EU Plug Upgrade Version Coffee and Black only $$352.94

Gearbest Creality 3D Ender-3 V-slot Prusa I3 DIY 3D Printer Kit 220 x 220 x 250mm Printing Size - EU Plug Black
Creality 3D Ender-3 V-slot Prusa I3 DIY 3D Printer Kit 220 x 220 x 250mm Printing Size - EU Plug Black only $$153.84

Gearbest Alfawise U20 Large Scale 2.8 inch Touch Screen DIY 3D Printer - EU - U20 EU Plug Black
Alfawise U20 Large Scale 2.8 inch Touch Screen DIY 3D Printer - EU - U20 EU Plug Black only $$253.39