Modbus coils and switches code example

Hey Anyone can provide a simple code which is working and updating button status for modbus relays?

new version simply does not work good