This repository has been archived on 2024-08-19. You can view files and clone it, but cannot push or open issues or pull requests.
Arduino/sketch_nov24b.ino
2023-06-13 12:35:15 +03:00

51 lines
1.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <SoftwareSerial.h>
// Назначение задействованных дискретных каналов
SoftwareSerial softSerial(8, 9); // RX, TX
// Дискретный канал, на котором висит встроенный светодиод
int LED = 13;
void setup(){
softSerial.begin(9600); // Инициализация программного последовательного порта
pinMode(LED, OUTPUT); // Определение светодиодного вывода как выход
}
void loop(){
// Проверяем, есть ли что-нибудь в буфере программного последовательного порта
if (softSerial.available()){
// Читаем один символ из буфера программного последовательного порта и сохраняем его переменную com
int com = softSerial.read();
// Действуем соответственно полученному символу
if (com == 'x'){
// Выключение светодиода
digitalWrite(LED, LOW);
softSerial.write("off");
}
else if (com == 'a'){
// Включение светодиода
digitalWrite(LED, HIGH);
softSerial.write("on");
}
}
}