It depends on who's hmi / plc you are using. I will give one example an we can go from there. the most common way of interfacing a plc with an hmi in the indusrial world is called modbus. In modbus, you assign buttons, switches, indicators in your hmi to values like 00001, 10001, 40001, etc. The first number indicates whether you want to read, write a bit or a piece of data. As long as these match to the contacts, coils, data registers in the plc, and you have everything hooked up correctly and the comm protocols are set up the same on both ends, changing the state of an object in the hmi will change that same object in the plc and a change in a plc object will change the state of an inicator on the hmi side. I hope that helps, if not, try to be as specific as possible, I can probably help.