Project/project/project.ino

21 lines
374 B
C++

#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);
}