programing

Hello friends! Please help me very much. This program is the nixe clock. I would like to turn mosfet D10 or D 11 pin, from 9 am to 21 pm every 1 hour, every day during 10 seconds . Please correct the code please.

Thanks!!! :slight_smile:

code in attachments.

#include "FastLED.h"//библиотека для работы с лентой
#include <iarduino_RTC.h>//библиотека для работы с rtc модулем
iarduino_RTC time(RTC_DS3231);
const int def_pin[] = {A3, A1, A0, A2};//выводы для дешифратора defPin[out1,out2,out4,out8];
const char dictionary_of_number[10][4] = { //словарь цифр
{1, 0, 0, 1},//0
{0, 0, 0, 1},//1
{0, 0, 0, 0},//2
{1, 0, 1, 0},//3
{0, 1, 1, 0},//4
{0, 1, 0, 0},//5
{1, 1, 0, 0},//6
{1, 1, 1, 0},//7
{0, 0, 1, 0},//8
{1, 0, 0, 0},//9
};
#define LED_COUNT 6// число светодиодов в кольце/ленте
#define LED_DT 9// пин, куда подключен DIN ленты
const int keys_pin[] = {8, 7, 6, 5, 4, 2};// выводы для транзисторных ключей
// ---------------СЛУЖЕБНЫЕ ПЕРЕМЕННЫЕ-----------------
struct CRGB leds[LED_COUNT];
int ledsX[LED_COUNT][3];

int idex = 0; //-LED INDEX (0 to LED_COUNT-1
int ihue = 0; //-HUE (0-255)
int ibright = 0; //-BRIGHTNESS (0-255)
int isat = 0; //-SATURATION (0-255)
int bouncedirection = 0; //-SWITCH FOR COLOR BOUNCE (0-1)
// ---------------СЛУЖЕБНЫЕ ПЕРЕМЕННЫЕ-----------------

String input_string = "";
int time_date[] = {0, 0, 0, 0, 0, 0}; // массив где хранится временя или дата
int mass_brightness[] = {0, 0, 0};//значение светодиодов
bool swap_time_date = true, open_scroll = false; // булевые переменные для органиции смеды даты и времени
unsigned long last_scroll = 0, last_step = 0, interval_scroll = 300000;//переменные для задержек
int p = 7, k = 0; //переменные для счетчиков
int led_mod = 1, quotient_bright = 200, amount_led_mod = 6, this_value = 255; // переменные для подцветки

void setup() {
// задаем частоту ШИМ на 3 выводе 30кГц
TCCR2B = TCCR2B & 0b11111000 | 0x01;
analogWrite(3, 90); //если запитывать от блока питания 9в
//задаем режим работы выходов микроконтроллера
for (int i = 0; i < 4; i++) {
pinMode(def_pin*, OUTPUT);*

  • }*
  • for (int i = 0; i < 6; i++) {*
    pinMode(keys_pin*, OUTPUT);
    _
    }_
    LEDS.setBrightness(quotient_bright); // ограничить максимальную яркость*

    * LEDS.addLeds<WS2811, LED_DT, GRB>(leds, LED_COUNT); // настрйоки для нашей ленты (ленты на WS2811, WS2812, WS2812B)
    one_color_all(mass_brightness[0], mass_brightness[1], mass_brightness[2]);// погасить все светодиоды*

    * LEDS.show();// отослать команду*
    * Serial.begin(9600);*
    * time.begin();*
    }
    void loop() {
    * k++;//счетчик для мигания цифрами*
    * //читаем порт если там что-то есть.*
    * while (Serial.available() > 0) {*
    * char c = Serial.read();*
    * //считываем пока нет перехода на следующую строку*
    * if (c == '\n') {*
    * menu(input_string);//передаем строку в обработчик*
    * input_string = "";
    _
    }_
    _
    else {_
    input_string += c;
    _
    }_
    _
    }... _
    IN-14_v2_bluetooth_ws2812b.ino (12.1 KB)*

discjokey:
. Please correct the code please.

You have not told us what the program actually does.

To make it easy for people to help you please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum

...R

10 seconds ON at the start of every hour from 9:00 through 21:00. Otherwise OFF.

  if (hour >= 9 && hour <= 21 && minute == 0 && second < 10)
    digitalWrite(11, HIGH);
  else
    digitalWrite(11, LOW);

johnwasser:
10 seconds ON at the start of every hour from 9:00 through 21:00. Otherwise OFF.

  if (hour >= 9 && hour <= 21 && minute == 0 && second < 10)

digitalWrite(11, HIGH);
  else
    digitalWrite(11, LOW);

I usually prefer to do this kind of code by using a serial minute

const int start = 9 * 60 + 0;
const int end = 21 * 60 + 0;

  int time = hour * 60 + minute;

  if(time >= start && time < end) 
    digitalWrite(11, HIGH);
  else
    digitalWrite(11, LOW);

PaulMurrayCbr:
I usually prefer to do this kind of code by using a serial minute

const int start = 9 * 60 + 0;

const int end = 21 * 60 + 0;

int time = hour * 60 + minute;

if(time >= start && time < end)
   digitalWrite(11, HIGH);
 else
   digitalWrite(11, LOW);

But that turns the pin on for the entire 12 hours 9:00:00 to 21:00:00, not just the first 10 seconds of each hour. That buzzer is going to get annoying after a while. :slight_smile:

I usually prefer to do this kind of code by using a serial minute

What IS a "serial minute"?

PaulS:
What IS a "serial minute"?

The length of time one should masticate a mouthful of cornflakes?

...R