Tell me please in detail by skchechu

#define BLED 9                                         //9 контакт для синего вывода RGB-светодиода
#define GLED 10                                        //10 контакт для зеленого вывода RGB-светодиода
#define RLED 11                                        //11 контакт для красного вывода RGB-светодиода
#define BUTTON 2                                       //2 контакт для кнопки
boolean lastButton = LOW;                              //предыдущее состояние кнопки
boolean currentButton = LOW;                           //текущее состояние кнопки
int ledMode = 0;                                       //статус  RGB-светодиода
void setup(){
  pinMode (BLED, OUTPUT);                              //Устанавливаем контакт BLED(Blue LED, т.е 9 контакт) как выход
  pinMode (GLED, OUTPUT);                              //Устанавливаем контакт GLED(Green LED, т.е 9 контакт) как выход
  pinMode (RLED, OUTPUT);                              //Устанавливаем контакт RLED(Red LED, т.е 9 контакт) как выход
  pinMode (BUTTON, INPUT);                             //Устанавливаем контакт BUTTON(т.е. 2 контакт) как вход(опционально)
  digitalWrite(2, HIGH);                               //подключаем подтягивающий резистор
}
void loop(){
  currentButton = debounce(lastButton);                //считываем состояние кнопки с применением "антидребезга"
  if (lastButton == LOW && currentButton == HIGH)      //если кнопка была нажата
  {
    ledMode++;                                         //инкрементируем значение переменной
  }
  lastButton = currentButton;                          //сохраняем текущее состояние кнопки в предыдущее
  if (ledMode == 4) ledMode = 0;                      //если прошли по циклу все режимы свечения светодиода, делаем сброс до 0
  setMode(ledMode);                                   //изменить режим светодиода
}
 
/*
* Функция антидребезга
* принимает предыдущее значение кнопки и возвращает текущее состояние кнопки с подавлением дребезга контактов
*/
boolean debounce(boolean last)
{
  boolean current = digitalRead(BUTTON);             //считываем состояние кнопки
  if (last != current)                               //если есть изменения
  {
    delay(5);                                        //ждем 5мс
    current = digitalRead(BUTTON);                   //считываем состояние кнопки
  }
  return current;                                    //возвращаем, считанное состояние кнопки
}
 
/*
* Выбор режима работы светодиода
* Передача номера режима и его установка
* Функция ничего не возвращает
*/
void setMode(int mode)
{
  //Красный
  if (mode == 1)
  {
    digitalWrite(RLED, LOW);
    digitalWrite(GLED, HIGH);
    digitalWrite(BLED, HIGH);
  }
  //Зеленый
  else if (mode == 2)
  {
    digitalWrite(RLED, HIGH);
    digitalWrite(GLED, HIGH);
    digitalWrite(BLED, LOW);
  }
  //Синий
  else if (mode == 3)
  {
    digitalWrite(RLED, HIGH);
    digitalWrite(GLED, LOW);
    digitalWrite(BLED, HIGH);
  }
  else
  {
    digitalWrite(RLED, -255);
    digitalWrite(GLED, -255);
    digitalWrite(BLED, -255);
  }
}

Есть скеч, управляет rgb диодом, при нажатии на кнопку включает красный, потом синий, потом зеленый цвет (примерный порядок) при последнем нажатии полностью гасит его.
У меня два вопроса первый что конкретно делает что происходит при ?
There is a scratch, it controls the RGB diode, when you press the button it turns on red, then blue, then green (approximate order), then completely extinguishes it.
What exactly happens when?

digitalWrite(RLED, -255);
    digitalWrite(GLED, -255);
    digitalWrite(BLED, -255);

и одно ли и тоже что digitalWrite(PIN, -255); и digitalWrite(PIN, 0); digitalWrite(PIN, LOW); и analogWrite(PIN, 0); ?
and is it the same as digitalWrite (PIN, -255); and digitalWrite(PIN, -255); and digitalWrite (PIN, LOW); and analogWrite (PIN, 0); ?

What exactly happens when?

digitalWrite(RLED, -255);

digitalWrite(GLED, -255);
   digitalWrite(BLED, -255);

not clear. -255 should be HIGH to turn all LEDS off, or LOW to turn all on

digitalWrite(pin, 0); = digitalWrite(pin, low);
digitalWrite(pin, 255); = digitalWrite(pin, high);
analogWrite (PIN, 0); = digitalWrite(pin, 0); or = digitalWrite(pin, low);
analogWrite (PIN, 255); = digitalWrite(pin, 255); or = digitalWrite(pin, high);

right ?
есть ли какая то программа которая докажет, что несмотря на написание скеча по разному, он делает одно и тоже, и при загрузке в ардуино, код выглядит - исполняется одинаково ?
is there some kind of program that proves that despite writing a sketch in different ways, it does the same thing, and when loaded into arduino, the code looks like - it runs the same?
а главное что эти строчки, не причинят вред ардуино ? верно ?
and most importantly, that these lines do not harm arduino? right ?

digitalWrite(RLED, -255);
    digitalWrite(GLED, -255);
    digitalWrite(BLED, -255);

может кто рассказать подробно что происходит при том когда указываешь значение с минусом ?
can anyone tell in detail what happens when you specify a value with a minus ?
digitalWrite(pin, -255)
читал об этом, но сейчас не могу найти информацию
read about it, but now I can not find the information
читал об этом, но сейчас не могу найти информацию
read about it, but now I can not find the information

The constant "-255" is interpreted as an int with a value of 0xFF01 which is cast (truncated) to a uint8_t by digitalWrite, which uses the truncated value 0x01, or 1.

However, the compiler may optimize it and perform this truncation at compile time.

can anyone tell in detail what happens when you specify a value with a minus ?

when i tried setting a pin to a "byte" var set to -255 using digitalWrite() it did the same thing as setting it HIGH. a print displayed it as "1"

is there some kind of program that proves that despite writing a sketch in different ways, it does the same thing, and when loaded into arduino, the code looks like - it runs the same?

when i'm trying to develop code that isn't hardware specific, i'll develop the code in simulation on my laptop
using stubs for Arduino functions such as digitalWrite(), millis(), ... the stub routing can do prints to indicate when they are called and with what parameters.

3FX:
can anyone tell in detail what happens when you specify a value with a minus ?

Google "2's complement arithmetic".

1 ? хммм странно
дело в том что я купил rgb диоды,(разные и с анодом и с катодом) и пытался получить их полное затухание разными способами
1 ? hmmm weird
the fact is that I bought rgb diodes, (different with both the anode and cathode) and tried to get their complete attenuation in different ways

analogWrite(RLED, 0-255);
    analogWrite(GLED, 0-255);
    analogWrite(BLED, 0-255);
or
digitalWrite(RLED, HIGH);
    digitalWrite(GLED, HIGH);
    digitalWrite(BLED, HIGH);
or
digitalWrite(RLED, LOW);
    digitalWrite(GLED, LOW);
    digitalWrite(BLED, LOW);
но сработало только это
but it only worked
digitalWrite(RLED, -255);
    digitalWrite(GLED, -255);
    digitalWrite(BLED, -255);

и значение -255 дает больше чем просто 1
Ну не важно, спасибо за помощь.
and a value of -255 gives more than just 1
Well, it doesn’t matter, thanks for the help.