Skip to content

Proteus 8 #1854

Description

@Seregaassd

friends, I am writing as a translator, I need help (I am writing a diploma), I generated the code for the board, but it throws errors, who from the height of their experience can fix it, it is very necessary for the anchor in the relay to close and the light to light, the components should be these, but maybe the principle should be changed or you will see errors in the code.

Image
.........................................................................................................................................................................................
const int pressurePin = A0; // Подключение Vout датчика давления к A0
const int relayPin = 22; // Подключение реле к пину 22

void setup() {
pinMode(relayPin, OUTPUT); // Устанавливаем пин реле как выход
digitalWrite(relayPin, LOW); // Убедимся, что реле выключено
Serial.begin(9600); // Инициализация последовательного порта для отладки
}

void loop() {
// Чтение значения с датчика давления
int sensorValue = analogRead(pressurePin);

// Преобразование значения в напряжение (0-5В)
float voltage = sensorValue * (5.0 / 1023.0);

// Преобразование напряжения в давление (зависит от характеристик вашего датчика)
// MPX4250: 0.2V при 0 PSI и 4.7V при 25 PSI (для примера)
float pressure = (voltage - 0.2) * (25.0 / (4.7 - 0.2)); // примерное преобразование

Serial.print("Давление: ");
Serial.println(pressure); // Запись давления в последовательный монитор

// Условие для включения реле:
// Например, включаем реле, если давление выше 5 PSI
if (pressure > 5.0) {
digitalWrite(relayPin, HIGH); // Включаем реле
} else {
digitalWrite(relayPin, LOW); // Выключаем реле
}

delay(500); // Задержка для следующего считывания
}
......................................................................................................................................................................................................

Image

if someone can send pictures of this lamp in operation, I will be really grateful, because it is somehow difficult, the versions are such that AVR2.DLL writes an error, I looked on your forum, I could not figure it out, maybe a knowledgeable person will help, thanks

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions