Recoded to work with analog sensors.