Compare commits

..

9 Commits

Author SHA1 Message Date
4efdbb3d63 add OTA 2025-02-16 14:18:09 +01:00
471bfbe6ac +LEDs RGB, fix Brightness input 2023-10-13 14:40:47 +02:00
268be2953b ajout clignotement des secondes sur Nixie3 2023-08-04 21:10:41 +02:00
124b05be2d Avec 4 Nixies multiplexés 2023-07-28 12:35:54 +02:00
453e6dbd22 Meilleurs initialisations wifi/ntp/rtc 2023-07-10 22:17:09 +02:00
daa915b5c7 précisions des commentaires 2023-06-06 15:06:45 +02:00
deedda25b8 MAJ commentaires de code et TODO Liste dans le readme 2023-06-06 11:37:50 +02:00
55ca79e431 Fonctionnalités ok : Wifi (basique), NTP, RTC.
TODO : gestion d'erreurs.
2023-06-06 11:05:49 +02:00
0f028e6757 debut de pilotage Nixie
debut de connexion wifi
debut de réupération heure en ntp
2023-06-05 10:03:29 +02:00
11 changed files with 68308 additions and 118 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
secrets.h

View File

@ -1,80 +1,331 @@
/*
* Created by Laurent CLaude
* https://www.laurentclaude.fr/
*
* This code is in license GPL v3
* My code is under license GPL v3
*
* Horloge Nixie basée sur ESP + module RTC-DS1307, avec fonctionnalités wifi pour synchro NTP
*/
#include "hardware.h"
#include "nixie.h"
#include "secrets.h"
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
#include <WiFiUdp.h>
#include <RTClib.h> // Date and time functions using a DS1307 RTC connected via I2C and Wire lib. https://github.com/adafruit/RTClib
#include <NTP.h> // The NTP library allows you to receive time information from the Internet. https://github.com/sstaub/NTP
#include "nixie.h" // Mes routines de pilotage d'affichage Nixie
#include <FastLED.h> // https://github.com/FastLED/FastLED
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include <RTClib.h>
#include <ESPmDNS.h>
#include <NetworkUdp.h>
#include <ArduinoOTA.h>
// Les affectations physiques
// event at to 14:45 (for tests)
uint8_t DAILY_EVENT_HH = 14; // event start time: hour
uint8_t DAILY_EVENT_MM = 45; // event start time: minute
// Number of leds in your strip
#define NUM_LEDS 4
#define LEDS_PIN 43
// Define the array of leds
CRGB leds[NUM_LEDS];
RTC_DS1307 rtc;
char daysOfTheWeek[7][12] = { "Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi" };
bool wifiOK, ntpOK, rtcOK;
unsigned long LastRTCUpdate; // le temps de dernière MAJ de l'horloge interne RTC
unsigned long LastNixieUpdate; // le temps de dernière MAJ affichage Nixie
unsigned long LastDotUpdate; // le temps de dernière MAJ de l'affichage du point des secondes
unsigned long LastLedUpdate; // le temps de dernière MAJ des leds RGB
int heu_d, heu_u, min_d, min_u, sec_d, sec_u;
byte brightnessInput, brightnessLeds ; //for RGB led brightness
byte randomR, randomG, randomB; // for RGB led random colors
char daysOfTheWeek[7][12] = {
"Dimanche",
"Lundi",
"Mardi",
"Mercredi",
"Jeudi",
"Vendredi",
"Samedi"
};
const long intervalRTCUpdate = 600000; // 86400000 = 24 heures / 3600000 = 1 heure / 600000 = 10 minutes
const long intervalNixieUpdate = 1000; // 1000 = 1 seconde
void setup () {
Serial.begin(115200);
Wire.begin(I2C_SDA,I2C_SCL); // Broches (SDA,SCL) de l'I2C pour la RTC
WiFiUDP wifiUdp;
NTP ntp(wifiUdp);
// SETUP RTC MODULE
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
while (1);
/////////////////////////////////////////////////////
//////////// FONCTIONS ////////////////
/////////////////////////////////////////////////////
//
bool initWIFI() {
//WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
WiFiManager wm;
bool reso;
wm.setConfigPortalTimeout(60);
wm.setHostname("HorlogeNixie");
//reset settings if switch pressed on startup
if (!digitalRead(Rotary_SW)) {
Serial.println("RAZ wifi");
wm.resetSettings();
}
// sets the RTC to the date & time on PC this sketch was compiled
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
reso = wm.autoConnect("NixieClockAP"); // Création d'un AP ou connexion mémorisée
//reso = wm.autoConnect(SECRET_WIFI_SSID, SECRET_WIFI_PASS);
// sets the RTC with an explicit date & time, for example to set
// January 21, 2021 at 3am you would call:
// rtc.adjust(DateTime(2021, 1, 21, 3, 0, 0));
}
void loop () {
DateTime now = rtc.now();
printTime(now);
if (now.hour() == DAILY_EVENT_HH &&
now.minute() == DAILY_EVENT_MM) {
Serial.println("It is on scheduled time");
// TODO: write your code"
if (reso) {
//if you get here you have connected to the WiFi
Serial.println("Connected...yeey :)");
} else {
Serial.println("It is NOT on scheduled time");
Serial.println("Failed to connect");
}
delay(1000);
return (reso);
}
void printTime(DateTime time) {
Serial.print("Date : ");
Serial.print(time.year(), DEC);
Serial.print('/');
Serial.print(time.month(), DEC);
Serial.print('/');
Serial.print(time.day(), DEC);
Serial.print(" (");
Serial.print(daysOfTheWeek[time.dayOfTheWeek()]);
Serial.print(") - Heure : ");
Serial.print(time.hour(), DEC);
Serial.print(':');
Serial.print(time.minute(), DEC);
Serial.print(':');
Serial.println(time.second(), DEC);
bool initRTC() {
//// Initialisation RTC
Serial.print("Initialisation de l'horloge interne RTC");
rtcOK = rtc.begin();
if (!rtcOK) {
Wire.begin(I2C_SDA, I2C_SCL); // Broches (SDA,SCL) de l'I2C pour la RTC
delay(1000);
if (!rtc.begin()) {
Serial.println(" --> RTC introuvable !");
return (false);
} else {
Serial.println(" : OK");
return (true);
}
} else {
Serial.println(" : déjà démarrée !");
return (true);
}
}
void printRTC() {
//// Affichage du temps RTC en console série pour débug
DateTime now = rtc.now();
Serial.print("Heure de l'horloge interne (RTC) : ");
Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
Serial.print(" ");
Serial.print(now.day(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.year(), DEC);
Serial.print(" ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.println(now.second(), DEC);
}
void initNTP() {
// Paramétrage NTP avec prise en compte de l'heure d'été pour la France
Serial.print("Initialisation NTP");
ntp.ruleDST("CEST", Last, Sun, Mar, 2, 120); // last sunday in march 2:00, timetone +120min (+1 GMT + 1h summertime offset)
ntp.ruleSTD("CET", Last, Sun, Oct, 3, 60); // last sunday in october 3:00, timezone +60min (+1 GMT)
ntp.begin();
Serial.println(" : OK");
//ntp.updateInterval(1000); // update every second
Serial.print("Le temps Internet (NTP) indique : ");
ntp.update();
Serial.println(ntp.formattedTime("%A %d/%m/%Y %T")); // www dd/mm/yyyy hh:mm:ss
}
void syncNTPtoRTC() {
//// Récupération du temps Internet par NTP
Serial.println("Synchro temps NTP vers RTC :");
Serial.print("- récupération du temps Internet : ");
ntp.update(); // récupération du temps NTP
Serial.println(ntp.formattedTime("%A %d/%m/%Y %T")); // www dd/mm/yyyy hh:mm:ss
//// Mise à jour du temps RTC de l'horloge locale
Serial.print("- enregistrement du temps Internet dans l'horlore RTC");
rtc.adjust(DateTime(ntp.year(), ntp.month(), ntp.day(), ntp.hours(), ntp.minutes(), ntp.seconds()));
Serial.println(" : OK.");
LastRTCUpdate = millis();
}
/////////////////////////////////////////////////////
/////////////////// setup ////////////////////
/////////////////////////////////////////////////////
//
void setup() {
//// Initialisation hardware
pinMode(Rotary_SW, INPUT_PULLUP); // Encodeur rotatif : switch
pinMode(Rotary_A, INPUT_PULLUP); // Encodeur rotatif : voie A
pinMode(Rotary_B, INPUT_PULLUP); // Encodeur rotatif : voie B
pinMode(BCD_D, OUTPUT); // D Pour digits afficheurs Nixie
pinMode(BCD_C, OUTPUT); // C
pinMode(BCD_B, OUTPUT); // B
pinMode(BCD_A, OUTPUT); // A
pinMode(NX1A, OUTPUT); // Nixie 1
pinMode(NX2A, OUTPUT); // Nixie 2
pinMode(NX3A, OUTPUT); // Nixie 3
pinMode(NX4A, OUTPUT); // Nixie 4
// Démarrage de l'I2C :
Wire.begin(I2C_SDA, I2C_SCL); // Broches (SDA,SCL) de l'I2C pour la RTC
//// Initialisation de la liaison série
Serial.begin(115200);
Serial.println("");
Serial.println("Liaison série OK");
//// Initialisation des LEDs RGB
FastLED.addLeds<WS2812B, LEDS_PIN>(leds, NUM_LEDS); // GRB ordering is typical - avant : FastLED.addLeds<WS2812B, LEDS_PIN, RGB>(leds, NUM_LEDS);
FastLED.setBrightness(16);
leds[0] = CRGB::Black;
FastLED.show();
randomR = random(256);
randomG = random(256);
randomB = random(256);
wifiOK = initWIFI(); // initialisation du wifi
initNTP(); // récupération du temps Internet
rtcOK = initRTC(); // initialisation de l'horloge interne
if (wifiOK && rtcOK) {
printRTC(); // Affichage du temps RTC en console série
syncNTPtoRTC(); // Mise à l'heure de l'horloge RTC locale avec l'heure Internet
printRTC(); // Affichage du temps RTC en console série
}
// Port defaults to 3232
// ArduinoOTA.setPort(3232);
// Hostname defaults to esp3232-[MAC]
// ArduinoOTA.setHostname("myesp32");
// No authentication by default
// ArduinoOTA.setPassword("admin");
// Password can be set with it's md5 value as well
// MD5(admin) = 21232f297a57a5a743894a0e4a801fc3
// ArduinoOTA.setPasswordHash("21232f297a57a5a743894a0e4a801fc3");
ArduinoOTA
.onStart([]() {
String type;
if (ArduinoOTA.getCommand() == U_FLASH) {
type = "sketch";
} else { // U_SPIFFS
type = "filesystem";
}
// NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
Serial.println("Start updating " + type);
})
.onEnd([]() {
Serial.println("\nEnd");
})
.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
})
.onError([](ota_error_t error) {
Serial.printf("Error[%u]: ", error);
if (error == OTA_AUTH_ERROR) {
Serial.println("Auth Failed");
} else if (error == OTA_BEGIN_ERROR) {
Serial.println("Begin Failed");
} else if (error == OTA_CONNECT_ERROR) {
Serial.println("Connect Failed");
} else if (error == OTA_RECEIVE_ERROR) {
Serial.println("Receive Failed");
} else if (error == OTA_END_ERROR) {
Serial.println("End Failed");
}
});
ArduinoOTA.begin();
Serial.println("Ready");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
Serial.print("Pour info, le temps de compil : ");
Serial.print(__DATE__);
Serial.print(" - ");
Serial.println(__TIME__);
Serial.println("Fin des initialisations.");
printRTC(); // Affichage du temps RTC en console série
Serial.println("------------------------");
}
/////////////////////////////////////////////////////
///////////////// loop //////////////////
/////////////////////////////////////////////////////
//
void loop() {
ArduinoOTA.handle();
unsigned long currentMillis = millis();
// Mise à jour de l'affichage Nixie
if ((currentMillis - LastNixieUpdate >= intervalNixieUpdate) || (currentMillis < LastNixieUpdate)) {
LastNixieUpdate = currentMillis;
DateTime now = rtc.now();
heu_d = (now.hour()) / 10;
heu_u = (now.hour()) % 10;
min_d = (now.minute()) / 10;
min_u = (now.minute()) % 10;
sec_d = (now.second()) / 10;
sec_u = (now.second()) % 10;
// Si c'est la nuit alors réduire la luminosité des leds
if ((now.hour()> 21) || (now.hour() < 8)) {
FastLED.setBrightness(10);
} else {
brightnessInput = analogRead(IN_PHOTO_R); // read the input pin
FastLED.setBrightness(brightnessInput/2);
}
}
// Mise à jour de l'affichage des led RGB x fois par seconde
if ((currentMillis - LastLedUpdate > 50) || (currentMillis < LastLedUpdate)) {
LastLedUpdate = currentMillis;
randomR += random(3) - 1;
randomG += random(3) - 1;
randomB += random(3) - 1;
byte aupif = random(4);
leds[aupif] = CRGB(randomR, randomG, randomB);
FastLED.show();
}
// allumage du point x seconde puis éteint x seconde
// utilisation du digit "9" du Nixie 3 (dizaines de minutes)
if ((currentMillis - LastDotUpdate < 1000) || (currentMillis < LastDotUpdate)) {
printNixie3(9);
delay(5);
digitalWrite(NX3A, 0); //Switch OFF Anode Nixie 3
} else {
if ((currentMillis - LastDotUpdate < 2000) || (currentMillis < LastDotUpdate)) {
delay(5);
} else {
LastDotUpdate = currentMillis;
}
}
printNixie1(heu_d);
delay(5);
digitalWrite(NX1A, 0); //Switch OFF Anode Nixie 1
printNixie2(heu_u);
delay(5);
digitalWrite(NX2A, 0); //Switch OFF Anode Nixie 2
printNixie3(min_d);
delay(5);
digitalWrite(NX3A, 0); //Switch OFF Anode Nixie 3
printNixie4(min_u);
delay(5);
digitalWrite(NX4A, 0); //Switch OFF Anode Nixie 4
// Mise à jour de l'horloge interne RTC. Une fois par 24H
if ((currentMillis - LastRTCUpdate >= intervalRTCUpdate) || (currentMillis < LastRTCUpdate)) {
LastRTCUpdate = currentMillis;
syncNTPtoRTC(); // Mise à l'heure de l'horloge RTC locale avec l'heure Internet
printRTC(); // Affichage du temps RTC en console série
}
}

View File

@ -1 +1,34 @@
Firmware ESP32 pour mon horloge Nixie
Firmware pour mon horloge Nixie sur ESP32
## Hardware utilisé
Voir mes schémas : https://code.laurentclaude.fr/laurent/Horloge_Nixie_Schematics
## Licence
Mon code est publié sous licence libre GNU GPL v3.
Mais tout n'est pas écrit par moi, consultez les licences correspondantes.
## Librairies utilisées :
WiFiManager - https://github.com/tzapu/WiFiManager
WiFiUdp -
RTClib - Date and time functions using a DS1307 RTC connected via I2C and Wire lib. https://github.com/adafruit/RTClib
NTP - The NTP library allows you to receive time information from the Internet. https://github.com/sstaub/NTP
## Personnalisation
## TODO :
Gestion des erreurs
- [En cours] WiFi : utiliser le Wifi Manager https://github.com/tzapu/WiFiManager
- [X] RTC : en cas d'echec de récupération du temps Internet
- [ ] Pas/Perte de réseau
- [ ]
- [ ]
Fonctionnalités
- [X] Remise à zéro par pression d'un BP au démarrage : config Wifi,
- [X] Syncro de l'heure par internet et prise en compte heure d'été
- [X] affichage de l'heure sur Nixie
- [En cours] Effets lumineux sur leds RGB
- [ ] ajustement de l'heure par encodeur rotatif
- [ ] Traitement parallélisé (synchro NTP via réso // affichage de l'heure)
- [ ]
- [ ]

15
boutsdecode.txt Normal file
View File

@ -0,0 +1,15 @@
// event at to 14:45 (for tests)
uint8_t DAILY_EVENT_HH = 14; // event start time: hour
uint8_t DAILY_EVENT_MM = 45; // event start time: minute
DateTime now = rtc.now();
printTime(now);
if (now.hour() == DAILY_EVENT_HH &&
now.minute() == DAILY_EVENT_MM) {
Serial.println("It is on scheduled time");
// TODO: write your code"
} else {
Serial.println("It is NOT on scheduled time");
}

14
debug.cfg Normal file
View File

@ -0,0 +1,14 @@
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Example OpenOCD configuration file for ESP32-S3 connected via builtin USB-JTAG adapter.
#
# For example, OpenOCD can be started for ESP32-S3 debugging on
#
# openocd -f board/esp32s3-builtin.cfg
#
# Source the JTAG interface configuration file
source [find interface/esp_usb_jtag.cfg]
# Source the ESP32-S3 configuration file
source [find target/esp32s3.cfg]

67571
debug.svd Normal file

File diff suppressed because it is too large Load Diff

17
debug_custom.json Normal file
View File

@ -0,0 +1,17 @@
{
"name":"Arduino on ESP32-S3",
"toolchainPrefix":"xtensa-esp32s3-elf",
"svdFile":"debug.svd",
"request":"attach",
"overrideAttachCommands":[
"set remote hardware-watchpoint-limit 2",
"monitor reset halt",
"monitor gdb_sync",
"thb setup",
"c"
],
"overrideRestartCommands":[
"monitor reset halt",
"monitor gdb_sync"
]
}

View File

@ -1,10 +1,27 @@
#include "Arduino.h"
// I2C (pour RTC)
#define I2C_SDA 2
#define I2C_SCL 14
#define I2C_SDA 42
#define I2C_SCL 41
// Sorties BCD vers Nixie
#define BCD_A 16
#define BCD_B 5
#define BCD_C 4
#define BCD_D 0
#define BCD_A 11
#define BCD_B 12
#define BCD_C 13
#define BCD_D 14
#define NX1A 4
#define NX2A 5
#define NX3A 6
#define NX4A 7
// sortie pilotage des LEDs WS2812B placées sous les Nixies
#define OUT_LEDs 43
// Entrée photo-résistance
#define IN_PHOTO_R 10
// Touches
#define Rotary_A 35
#define Rotary_B 36
#define Rotary_SW 37 // switch vers la masse (R pullup interne) pour réinit du wifi au démarrage (choisi au pif)

270
nixie.cpp
View File

@ -1,68 +1,332 @@
#include "esp32-hal-gpio.h"
#include "nixie.h"
#include "Arduino.h"
#include "hardware.h"
void printNixie(byte a){
void printNixie1(int8_t a) {
switch (a) {
case 0 :
case 0:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, LOW); //C
digitalWrite(BCD_B, LOW); //B
digitalWrite(BCD_A, LOW); //A
digitalWrite(NX1A, 1); //Switch ON Anode Nixie 1
break;
case 1:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, LOW); //C
digitalWrite(BCD_B, LOW); //B
digitalWrite(BCD_A, HIGH); //A
digitalWrite(NX1A, 1); //Switch ON Anode Nixie 1
break;
case 2:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, LOW); //C
digitalWrite(BCD_B, HIGH); //B
digitalWrite(BCD_A, LOW); //A
digitalWrite(NX1A, 1); //Switch ON Anode Nixie 1
break;
case 3:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, LOW); //C
digitalWrite(BCD_B, HIGH); //B
digitalWrite(BCD_A, HIGH); //A
digitalWrite(NX1A, 1); //Switch ON Anode Nixie 1
break;
case 4:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, HIGH); //C
digitalWrite(BCD_B, LOW); //B
digitalWrite(BCD_A, LOW); //A
digitalWrite(NX1A, 1); //Switch ON Anode Nixie 1
break;
case 5:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, HIGH); //C
digitalWrite(BCD_B, LOW); //B
digitalWrite(BCD_A, HIGH); //A
digitalWrite(NX1A, 1); //Switch ON Anode Nixie 1
break;
case 6:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, HIGH); //C
digitalWrite(BCD_B, HIGH); //B
digitalWrite(BCD_A, LOW); //A
digitalWrite(NX1A, 1); //Switch ON Anode Nixie 1
break;
case 7:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, HIGH); //C
digitalWrite(BCD_B, HIGH); //B
digitalWrite(BCD_A, HIGH); //A
digitalWrite(NX1A, 1); //Switch ON Anode Nixie 1
break;
case 8:
digitalWrite(BCD_D, HIGH); //D
digitalWrite(BCD_C, LOW); //C
digitalWrite(BCD_B, LOW); //B
digitalWrite(BCD_A, LOW); //A
digitalWrite(NX1A, 1); //Switch ON Anode Nixie 1
break;
case 9:
digitalWrite(BCD_D, HIGH); //D
digitalWrite(BCD_C, LOW); //C
digitalWrite(BCD_B, LOW); //B
digitalWrite(BCD_A, HIGH); //A
digitalWrite(NX1A, 1); //Switch ON Anode Nixie 1
break;
default:
digitalWrite(BCD_D, HIGH); //D
digitalWrite(BCD_C, HIGH); //C
digitalWrite(BCD_B, HIGH); //B
digitalWrite(BCD_A, LOW); //A
digitalWrite(BCD_A, HIGH); //A
digitalWrite(NX1A, 0); //Switch OFF Anode Nixie 2
break;
}
}
void printNixie2(int8_t a) {
switch (a) {
case 0:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, LOW); //C
digitalWrite(BCD_B, LOW); //B
digitalWrite(BCD_A, LOW); //A
digitalWrite(NX2A, 1); //Switch ON Anode Nixie 2
break;
case 1:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, LOW); //C
digitalWrite(BCD_B, LOW); //B
digitalWrite(BCD_A, HIGH); //A
digitalWrite(NX2A, 1); //Switch ON Anode Nixie 2
break;
case 2:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, LOW); //C
digitalWrite(BCD_B, HIGH); //B
digitalWrite(BCD_A, LOW); //A
digitalWrite(NX2A, 1); //Switch ON Anode Nixie 2
break;
case 3:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, LOW); //C
digitalWrite(BCD_B, HIGH); //B
digitalWrite(BCD_A, HIGH); //A
digitalWrite(NX2A, 1); //Switch ON Anode Nixie 2
break;
case 4:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, HIGH); //C
digitalWrite(BCD_B, LOW); //B
digitalWrite(BCD_A, LOW); //A
digitalWrite(NX2A, 1); //Switch ON Anode Nixie 2
break;
case 5:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, HIGH); //C
digitalWrite(BCD_B, LOW); //B
digitalWrite(BCD_A, HIGH); //A
digitalWrite(NX2A, 1); //Switch ON Anode Nixie 2
break;
case 6:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, HIGH); //C
digitalWrite(BCD_B, HIGH); //B
digitalWrite(BCD_A, LOW); //A
digitalWrite(NX2A, 1); //Switch ON Anode Nixie 2
break;
case 7:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, HIGH); //C
digitalWrite(BCD_B, HIGH); //B
digitalWrite(BCD_A, HIGH); //A
digitalWrite(NX2A, 1); //Switch ON Anode Nixie 2
break;
case 8:
digitalWrite(BCD_D, HIGH); //D
digitalWrite(BCD_C, LOW); //C
digitalWrite(BCD_B, LOW); //B
digitalWrite(BCD_A, LOW); //A
digitalWrite(NX2A, 1); //Switch ON Anode Nixie 2
break;
case 9:
digitalWrite(BCD_D, HIGH); //D
digitalWrite(BCD_C, LOW); //C
digitalWrite(BCD_B, LOW); //B
digitalWrite(BCD_A, HIGH); //A
digitalWrite(NX2A, 1); //Switch ON Anode Nixie 2
break;
default:
digitalWrite(BCD_D, HIGH); //D
digitalWrite(BCD_C, HIGH); //C
digitalWrite(BCD_B, HIGH); //B
digitalWrite(BCD_A, HIGH); //A
digitalWrite(NX2A, 0); //Switch off Anode Nixie 2
break;
}
}
void printNixie3(int8_t a) {
switch (a) {
case 0:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, LOW); //C
digitalWrite(BCD_B, LOW); //B
digitalWrite(BCD_A, LOW); //A
digitalWrite(NX3A, 1); //Switch ON Anode Nixie 3
break;
case 1:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, LOW); //C
digitalWrite(BCD_B, LOW); //B
digitalWrite(BCD_A, HIGH); //A
digitalWrite(NX3A, 1); //Switch ON Anode Nixie 3
break;
case 2:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, LOW); //C
digitalWrite(BCD_B, HIGH); //B
digitalWrite(BCD_A, LOW); //A
digitalWrite(NX3A, 1); //Switch ON Anode Nixie 3
break;
case 3:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, LOW); //C
digitalWrite(BCD_B, HIGH); //B
digitalWrite(BCD_A, HIGH); //A
digitalWrite(NX3A, 1); //Switch ON Anode Nixie 3
break;
case 4:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, HIGH); //C
digitalWrite(BCD_B, LOW); //B
digitalWrite(BCD_A, LOW); //A
digitalWrite(NX3A, 1); //Switch ON Anode Nixie 3
break;
case 5:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, HIGH); //C
digitalWrite(BCD_B, LOW); //B
digitalWrite(BCD_A, HIGH); //A
digitalWrite(NX3A, 1); //Switch ON Anode Nixie 3
break;
case 6:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, HIGH); //C
digitalWrite(BCD_B, HIGH); //B
digitalWrite(BCD_A, LOW); //A
digitalWrite(NX3A, 1); //Switch ON Anode Nixie 3
break;
case 7:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, HIGH); //C
digitalWrite(BCD_B, HIGH); //B
digitalWrite(BCD_A, HIGH); //A
digitalWrite(NX3A, 1); //Switch ON Anode Nixie 3
break;
case 8:
digitalWrite(BCD_D, HIGH); //D
digitalWrite(BCD_C, LOW); //C
digitalWrite(BCD_B, LOW); //B
digitalWrite(BCD_A, LOW); //A
digitalWrite(NX3A, 1); //Switch ON Anode Nixie 3
break;
case 9:
digitalWrite(BCD_D, HIGH); //D
digitalWrite(BCD_C, LOW); //C
digitalWrite(BCD_B, LOW); //B
digitalWrite(BCD_A, HIGH); //A
digitalWrite(NX3A, 1); //Switch ON Anode Nixie 3
break;
default:
digitalWrite(BCD_D, HIGH); //D
digitalWrite(BCD_C, HIGH); //C
digitalWrite(BCD_B, HIGH); //B
digitalWrite(BCD_A, HIGH); //A
digitalWrite(NX3A, 0); //Switch off Anode Nixie 3
break;
}
}
void printNixie4(int8_t a) {
switch (a) {
case 0:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, LOW); //C
digitalWrite(BCD_B, LOW); //B
digitalWrite(BCD_A, LOW); //A
digitalWrite(NX4A, 1); //Switch ON Anode Nixie 4
break;
case 1:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, LOW); //C
digitalWrite(BCD_B, LOW); //B
digitalWrite(BCD_A, HIGH); //A
digitalWrite(NX4A, 1); //Switch ON Anode Nixie 4
break;
case 2:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, LOW); //C
digitalWrite(BCD_B, HIGH); //B
digitalWrite(BCD_A, LOW); //A
digitalWrite(NX4A, 1); //Switch ON Anode Nixie 4
break;
case 3:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, LOW); //C
digitalWrite(BCD_B, HIGH); //B
digitalWrite(BCD_A, HIGH); //A
digitalWrite(NX4A, 1); //Switch ON Anode Nixie 4
break;
case 4:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, HIGH); //C
digitalWrite(BCD_B, LOW); //B
digitalWrite(BCD_A, LOW); //A
digitalWrite(NX4A, 1); //Switch ON Anode Nixie 4
break;
case 5:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, HIGH); //C
digitalWrite(BCD_B, LOW); //B
digitalWrite(BCD_A, HIGH); //A
digitalWrite(NX4A, 1); //Switch ON Anode Nixie 4
break;
case 6:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, HIGH); //C
digitalWrite(BCD_B, HIGH); //B
digitalWrite(BCD_A, LOW); //A
digitalWrite(NX4A, 1); //Switch ON Anode Nixie 4
break;
case 7:
digitalWrite(BCD_D, LOW); //D
digitalWrite(BCD_C, HIGH); //C
digitalWrite(BCD_B, HIGH); //B
digitalWrite(BCD_A, HIGH); //A
digitalWrite(NX4A, 1); //Switch ON Anode Nixie 4
break;
case 8:
digitalWrite(BCD_D, HIGH); //D
digitalWrite(BCD_C, LOW); //C
digitalWrite(BCD_B, LOW); //B
digitalWrite(BCD_A, LOW); //A
digitalWrite(NX4A, 1); //Switch ON Anode Nixie 4
break;
case 9:
digitalWrite(BCD_D, HIGH); //D
digitalWrite(BCD_C, LOW); //C
digitalWrite(BCD_B, LOW); //B
digitalWrite(BCD_A, HIGH); //A
digitalWrite(NX4A, 1); //Switch ON Anode Nixie 4
break;
default:
digitalWrite(BCD_D, HIGH); //D
digitalWrite(BCD_C, HIGH); //C
digitalWrite(BCD_B, HIGH); //B
digitalWrite(BCD_A, HIGH); //A
digitalWrite(NX4A, 0); //Switch off Anode Nixie 4
break;
}
}

View File

@ -2,4 +2,7 @@
#include "Arduino.h"
#include "hardware.h"
void printNixie(byte a);
void printNixie1(int8_t a);
void printNixie2(int8_t a);
void printNixie3(int8_t a);
void printNixie4(int8_t a);

4
secrets.h.default Normal file
View File

@ -0,0 +1,4 @@
// Change with your credentials and rename this file 'secrets.h'
#define SECRET_WIFI_SSID "YOUR_SSID"
#define SECRET_WIFI_PASS "YOUR_PASS"