Problem in arduino

My new Arduino always gives me an error

Problem uploading to board. See https://support.arduino.cc/hc/en-us/sections/360003198300 for suggestions.

I moved your topic to an appropriate forum category @de_mian5157 .

In the future, when creating a topic please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

Hi @de_mian5157. I'm going to ask you to provide the full verbose output from an upload attempt.


:red_exclamation_mark: This procedure is not intended to solve the problem. The purpose is to gather more information.


Please do this:

  1. Select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus.
    The "Preferences" dialog will open.
  2. Uncheck the box next to Show verbose output during: ☑ compile in the "Preferences" dialog.
  3. Check the box next to Show verbose output during: ☐ upload.
  4. Click the "OK" button.
    The "Preferences" dialog will close.
  5. Attempt an upload, as you did before.
  6. Wait for the upload to fail.
  7. You will see an "Upload error: ..." notification at the bottom right corner of the Arduino IDE window. Click the "COPY ERROR MESSAGES" button on that notification.
  8. Open a reply here on this forum topic by clicking the "Reply" button.
  9. Click the <CODE/> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
  10. Press the Ctrl+V keyboard shortcut (Command+V for macOS users).
    This will paste the error output from the upload into the code block.
  11. Move the cursor outside of the code block markup before you add any additional text to your reply.
  12. Click the "Reply" button to publish the post.
/ Визначення пінів для датчиків вологості
const int sensorPin1 = A0;
const int sensorPin2 = A1;
const int sensorPin3 = A2;
const int sensorPin4 = A3;

// Визначення пінів для світлодіодів (по три на кожен датчик)
// Датчик 1
const int led1_low = 2;
const int led1_medium = 3;
const int led1_high = 4;
// Датчик 2
const int led2_low = 5;
const int led2_medium = 6;
const int led2_high = 7;
// Датчик 3
const int led3_low = 8;
const int led3_medium = 9;
const int led3_high = 10;
// Датчик 4
const int led4_low = 11;
const int led4_medium = 12;
const int led4_high = 13;

// Визначення піна для зумера
const int buzzerPin = A4; // Приклад використання аналогового піна для зумера, можна використовувати і цифровий

// Порогові значення вологості (можливо, доведеться відкалібрувати для ваших датчиків)
const int DRY_THRESHOLD = 700;   // Якщо значення датчика вище цього, вважаємо, що сухо
const int LOW_MOISTURE_THRESHOLD = 500; // Трохи волого
const int MEDIUM_MOISTURE_THRESHOLD = 300; // Помірно волого
// Якщо значення нижче MEDIUM_MOISTURE_THRESHOLD, вважаємо, що сильно волого

// Змінні для відстеження часу для зумера
unsigned long previousMillis = 0;
const long interval =  1000; //
int buzzerBeepsCount = 0;
const int MAX_BEEPS = 20;

void setup() {
  // Налаштування пінів датчиків як вхідні
  pinMode(sensorPin1, INPUT);
  pinMode(sensorPin2, INPUT);
  pinMode(sensorPin3, INPUT);
  pinMode(sensorPin4, INPUT);

  // Налаштування пінів світлодіодів як вихідні
  pinMode(led1_low, OUTPUT);
  pinMode(led1_medium, OUTPUT);
  pinMode(led1_high, OUTPUT);

  pinMode(led2_low, OUTPUT);
  pinMode(led2_medium, OUTPUT);
  pinMode(led2_high, OUTPUT);

  pinMode(led3_low, OUTPUT);
  pinMode(led3_medium, OUTPUT);
  pinMode(led3_high, OUTPUT);

  pinMode(led4_low, OUTPUT);
  pinMode(led4_medium, OUTPUT);
  pinMode(led4_high, OUTPUT);

  // Налаштування піна зумера як вихідний
  pinMode(buzzerPin, OUTPUT);

  // Початкова ініціалізація світлодіодів - вимкнути всі
  turnOffAllLeds();

  // Ініціалізація послідовного порту для відладки
  Serial.begin(9600);
}

void loop() {
  // Читаємо значення з кожного датчика
  int moistureValue1 = analogRead(sensorPin1);
  int moistureValue2 = analogRead(sensorPin2);
  int moistureValue3 = analogRead(sensorPin3);
  int moistureValue4 = analogRead(sensorPin4);

  // Обробка даних для кожного датчика
  processSensorData(moistureValue1, led1_low, led1_medium, led1_high, "Датчик 1");
  processSensorData(moistureValue2, led2_low, led2_medium, led2_high, "Датчик 2");
  processSensorData(moistureValue3, led3_low, led3_medium, led3_high, "Датчик 3");
  processSensorData(moistureValue4, led4_low, led4_medium, led4_high, "Датчик 4");

  // Перевіряємо, чи потрібно увімкнути зумер
  checkBuzzerConditions(moistureValue1, moistureValue2, moistureValue3, moistureValue4);

  // Невелика затримка для стабільності
  delay(100);
}

// Функція для обробки даних одного датчика
void processSensorData(int moistureValue, int ledLow, int ledMedium, int ledHigh, String sensorName) {
  // Виводимо значення датчика для відладки
  Serial.print(sensorName);
  Serial.print(": ");
  Serial.println(moistureValue);

  // Вимикаємо всі світлодіоди для поточного датчика перед встановленням нового стану
  digitalWrite(ledLow, LOW);
  digitalWrite(ledMedium, LOW);
  digitalWrite(ledHigh, LOW);

  if (moistureValue >= DRY_THRESHOLD) {
    // Дуже сухо, світлодіоди не світяться
    // Вже вимкнені
  } else if (moistureValue >= LOW_MOISTURE_THRESHOLD) {
    // Трохи волого, горить один світлодіод
    digitalWrite(ledLow, HIGH);
  } else if (moistureValue >= MEDIUM_MOISTURE_THRESHOLD) {
    // Помірно волого, горять два світлодіоди
    digitalWrite(ledLow, HIGH);
    digitalWrite(ledMedium, HIGH);
  } else {
    // Сильно волого, горять три світлодіоди
    digitalWrite(ledLow, HIGH);
    digitalWrite(ledMedium, HIGH);
    digitalWrite(ledHigh, HIGH);
  }
}

// Функція для перевірки умов зумера
void checkBuzzerConditions(int m1, int m2, int m3, int m4) {
  unsigned long currentMillis = millis();

  // Якщо хоча б один датчик показує "дуже сухо", і пройшло 10 хвилин з останнього циклу пищання
  if ((m1 >= DRY_THRESHOLD || m2 >= DRY_THRESHOLD || m3 >= DRY_THRESHOLD || m4 >= DRY_THRESHOLD) && (currentMillis - previousMillis >= interval)) {
    previousMillis = currentMillis; // Оновлюємо час початку нового циклу
    buzzerBeepsCount = 0; // Скидаємо лічильник писків
  }

  // Якщо датчики показують "дуже сухо" і ми ще не зробили 20 писків у поточному циклі
  if ((m1 >= DRY_THRESHOLD || m2 >= DRY_THRESHOLD || m3 >= DRY_THRESHOLD || m4 >= DRY_THRESHOLD) && (buzzerBeepsCount < MAX_BEEPS)) {
    // Пищимо
    tone(buzzerPin, 1000); // Генеруємо звук частотою 1000 Гц
    delay(100);          // Пищимо 100 мс
    noTone(buzzerPin);   // Вимикаємо звук
    delay(100);          // Пауза між писками
    buzzerBeepsCount++;  // Збільшуємо лічильник писків
  } else if (buzzerBeepsCount >= MAX_BEEPS) {
    noTone(buzzerPin); // Переконаємось, що зумер вимкнений після 20 писків
  }
}

// Функція для вимкнення всіх світлодіодів
void turnOffAllLeds() {
  digitalWrite(led1_low, LOW);
  digitalWrite(led1_medium, LOW);
  digitalWrite(led1_high, LOW);

  digitalWrite(led2_low, LOW);
  digitalWrite(led2_medium, LOW);
  digitalWrite(led2_high, LOW);

  digitalWrite(led3_low, LOW);
  digitalWrite(led3_medium, LOW);
  digitalWrite(led3_high, LOW);

  digitalWrite(led4_low, LOW);
  digitalWrite(led4_medium, LOW);
  digitalWrite(led4_high, LOW);
}

I have merged your cross-posts @de_mian5157.

Cross-posting is against the Arduino forum rules. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend a lot of time investigating and writing a detailed answer on one topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting can result in a suspension from the forum.

In the future, please only create one topic for each distinct subject matter. This is basic forum etiquette, as explained in the "How to get the best out of this forum" guide. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

Which Arduino? Clone or original?

Try:
IDE >> TOOLS >> BOARD >> AVR BOARDS >> your board
IDE >> TOOLS >> PORT >> your port
IDE >> TOOLS >> PROCESSOR >> ATmega328P OLD BOOTLOADER
or
IDE >> TOOLS >> PROCESSOR >> ATmega328P