/*
  Template for Hmi Ethernet connection 
*/ 
#include <hmi.h>


// Enter a MAC address and IP address for your controller below.
// The IP address, gateway and subnet will be dependent on your local network:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,64);           
IPAddress gateway(192,168,0,1);
IPAddress subnet(255,255,255,0);


// Initialize the Ethernet server library
EthernetServer server(23);      


//Declaration of global variables here
int pwm_value;               //Received integer by the Hmi app (use a slider widget in the app)
int pot;                    //Integer variable to sent to the Hmi app. 

void setup() {
    Ethernet.begin(mac,ip,gateway,subnet);
    //Attach the global variables with the Hmi system here
    Hmi.pinMode(12,OUTPUT);                  //Pin 12 as an output pin for the PWM
    Hmi.attachIntIn(pwm_value,'a');              //Attach the variable pwm_value as an IN integer to the Hmi system with the name tag 'a'
    Hmi.attachIntOut(pot,'b');          //Attach the variable temp to the Hmi system with the name tag 'b'    
}
  
  
 void loop(){
     //Your code here
    analogWrite(12,pwm_value);                   //Set the pin 12 as a PWM pin and write it with pwm_value variable  
     
    pot=analogRead(5);                  //Read the analog pin 5 and save it in the temp variable
   
    Hmi.nEthernet(server); 
  }

