added code with accelerometer input