private static void VoltageRatioInput_VoltageRatioChange(object sender, Phidget22.Events.VoltageRatioInputVoltageRatioChangeEventArgs e)
 {
     if (lastSoapDispensingEventSent == null || (DateTime.Now - (DateTime)lastSoapDispensingEventSent).TotalSeconds > 30)
     {
         if (e.VoltageRatio > 0.9)
         {
             Console.WriteLine("Soap dispensed");
             lastSoapDispensingEventSent = DateTime.Now;
             clearHandWash();
             SendSoapDispensnig();
             Console.WriteLine("Soap event sent");
         }
     }
 }
    void ratioChangeCallback(object sender, Phidget22.Events.VoltageRatioInputVoltageRatioChangeEventArgs e)
    {
        // We have a lot of different VoltageRatioInput devices, so I'm being lazy by just checking against them
        // in the same callback. It will probably serve you better to make separate callbacks for the devices.

        // NOTE: You may notice that we're checking the data before we use it for most of the sensors. The Phidgets
        // tend to be very noisy and they don't hold a stable value, so you will probably need to similarly filter
        // your data to keep your inputs from jumping around.
        if (sender == thumbstickX)
        {
            translationChange.x += Mathf.Abs((float)e.VoltageRatio) > .035 ? (float)e.VoltageRatio : 0f;
        }
        else if (sender == thumbstickY)
        {
            translationChange.y += Mathf.Abs((float)e.VoltageRatio) > .035 ? (float)e.VoltageRatio : 0f;
        }
        else if (sender == turn10)
        {
            if (Mathf.Abs(prevRotation - (float)e.VoltageRatio) > .001f)
            {
                currRotation = (float)e.VoltageRatio;
                prevRotation = currRotation;
            }
        }
        else if (sender == slider)
        {
            if (prevWidth - (float)e.VoltageRatio > .005f)
            {
                currWidth = (float)e.VoltageRatio * .9f + .1f;
                prevWidth = currWidth;
            }
        }
        else if (sender == touch)
        {
            isTouched = e.VoltageRatio > .5;
        }
        else if (sender == magnet)
        {
            if (Mathf.Abs((float)e.VoltageRatio - .5f) > .015f)
            {
                shakePower = Mathf.Abs((float)e.VoltageRatio - .5f) * 2f;
            }
            else
            {
                shakePower = 0f;
            }
        }
    }
 private void ratioChangeCallback(object sender, Phidget22.Events.VoltageRatioInputVoltageRatioChangeEventArgs e)
 {
     if (sender == force0)
     {
         if ((float)e.VoltageRatio >= 0.05f && !force1Pressed && !force2Pressed)
         {
             force0Pressed = true;
         }
         else
         {
             force0Pressed = false;
         }
     }
     else if (sender == force1)
     {
         if ((float)e.VoltageRatio >= 0.05f && !force0Pressed && !force2Pressed)
         {
             force1Pressed = true;
         }
         else
         {
             force1Pressed = false;
         }
     }
     else if (sender == force2)
     {
         if ((float)e.VoltageRatio >= 0.05f && !force0Pressed && !force1Pressed)
         {
             force2Pressed = true;
         }
         else
         {
             force2Pressed = false;
         }
     }
     else if (sender == magnet3)
     {
         if (((float)e.VoltageRatio <= 0.49 || (float)e.VoltageRatio >= 0.51) && !magnet4Activated && !magnet5Activated)
         {
             magnet3Activated = true;
         }
         else
         {
             magnet3Activated = false;
         }
     }
     else if (sender == magnet4)
     {
         if (((float)e.VoltageRatio <= 0.49 || (float)e.VoltageRatio >= 0.51) && !magnet3Activated && !magnet5Activated)
         {
             magnet4Activated = true;
         }
         else
         {
             magnet4Activated = false;
         }
     }
     else if (sender == magnet5)
     {
         if (((float)e.VoltageRatio <= 0.49 || (float)e.VoltageRatio >= 0.51) && !magnet3Activated && !magnet4Activated)
         {
             magnet5Activated = true;
         }
         else
         {
             magnet5Activated = false;
         }
     }
 }