14.06 проверка на другом компе
This commit is contained in:
+23
-15
@@ -1,20 +1,28 @@
|
||||
#include <ModbusSerial.h>
|
||||
#include <ModbusSerial.h>
|
||||
const int GPIOCoil = 0;
|
||||
|
||||
// Define pins
|
||||
#define PIN_INPUT 3
|
||||
#define PIN_LED 13
|
||||
|
||||
// Create Modbus object
|
||||
ModbusSerial mb(Serial, 1); // Assuming slave ID is 1
|
||||
#define MySerial Serial // define serial port used, Serial most of the time, or Serial1, Serial2 ... if available
|
||||
|
||||
bool coils[10];
|
||||
int pinToRead = 2;
|
||||
|
||||
ModbusSerial mb (MySerial, 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);
|
||||
MySerial.begin (9600, MB_PARITY_NONE); // prefer this line in accordance with the modbus standard.
|
||||
while (! MySerial)
|
||||
;
|
||||
|
||||
mb.config (9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// mb.setIsts(0, digitalRead(pinToRead));
|
||||
// mb.task();
|
||||
int r = Serial.read();
|
||||
if (r >= 0){
|
||||
Serial.write(r);
|
||||
Serial.write(r);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user