 
     @config.pins, (pin) =>
       try
-        @_setPinMode pin.number, pin.action
+        @_setPinAction pin
       catch error
         @emit 'error', error
 


  _broadcastPins: =>
    pins = _.compact _.map(@config.pins, @_readPin)
    @emit 'message',
      version: 1
      topic: 'action'
      pins: pins
      response: true

  _clearPins: =>
    _.times 19, _setDigitalWrite

  _setPwmWrite: (pinNumber) =>
    pwm = new mraa.Pwm pinNumber

  _writePin: (pin) =>
    return unless _.contains ['digitalWrite', 'pwmWrite'], pin.action

    @_digitalWrite pin.number, pin.value if pin.action == 'digitalRead'
    @_pwmWrite pin.number, pin.value if pin.action == 'pwmWrite'

    {
      action: pin.action
      number: pin.number
      value:  pin.value
    }

module.exports = Tentacle
