 }
 
 /**
+ * Handel Read Coils (FC=01)
+ * write back the values from digital in pins (input status).
+ */
+void readCoils(uint16_t address, uint16_t length) {
+    // read coils state
+    for (int i = 0; i < length; i++) {
+        // write one boolean (1 bit) to the response buffer
+        slave.writeCoilToBuffer(i, digitalRead(address + i));
+    }
+}
+
+/**
  * Handel Read Holding Registers (FC=03)
- * write back the values from analog in pins (input registers).
- *
- * handler functions must return void and take:
- *      uint8_t  fc - function code
- *      uint16_t address - first register/coil address
- *      uint16_t length/status - length of data / coil status
+ * write back the values from eeprom (holding registers).
  */
-void readMemory(uint16_t address, uint16_t length) {
+void readMemory(uint8_t fc, uint16_t address, uint16_t length) {
     uint16_t value;
+    
+    // check the function code
+    if (fc == FC_READ_INPUT_REGISTERS) {
+        // read eeprom memory
+        readAnalogIn(address, length);
+        return;
+    }
     
     // read program memory
     for (int i = 0; i < length; i++) {

 * set digital output pins (coils) on and off
 */
void writeDigitlOut(uint8_t fc, uint16_t address, uint16_t status) {
    digitalWrite(address, status);
}

/**
 * Handel Write Holding Registers (FC=16)
 * write data into program.
 *
 * handler functions must return void and take:
 *      uint8_t  fc - function code
 *      uint16_t address - first register/coil address
 *      uint16_t length/status - length of data / coil status
 */
void writeMemory(uint8_t fc, uint16_t address, uint16_t length) {
    uint16_t value;

     */
    slave.cbVector[CB_READ_COILS] = readDigitalIn;
    slave.cbVector[CB_WRITE_COIL] = writeDigitlOut;
    slave.cbVector[CB_READ_REGISTERS] = readMemory;
    slave.cbVector[CB_WRITE_MULTIPLE_REGISTERS] = writeMemory;
    
    // start slave at baud 9600 on Serial
