added pin mode and PIR initialization functions