Files
Project/project/project.ino
T
2024-05-27 20:00:35 +03:00

21 lines
374 B
Arduino

#include <ModbusSerial.h>
// Define pins
#define PIN_INPUT 3
#define PIN_LED 13
// Create Modbus object
ModbusSerial mb(Serial, 1); // Assuming slave ID is 1
void setup() {
Serial.begin(9600);
pinMode(PIN_INPUT, INPUT);
pinMode(PIN_LED, OUTPUT);
}
void loop() {
int sensorVal = digitalRead(PIN_INPUT);
mb.task(); // Update Modbus communication
delay(500);
}