diff --git a/src/main.c b/src/main.c
index 16a6d1c57fbe39cf05c81211a39848aa02cf9b46..658461ddb44f13b0674bbe31945d638c130e9cd1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -122,19 +122,29 @@ void callback(uint gpio, uint32_t events)
 {
 
     volatile uint slice_num = pwm_gpio_to_slice_num(27);
-    volatile duration = pwm_get_counter(slice_num) * 42;
-    /* volatile uint another_slice_num = pwm_gpio_to_slice_num(27);
 
-    if (events & GPIO_IRQ_LEVEL_HIGH)
+    if (events & GPIO_IRQ_EDGE_FALL)
     {
-        volatile uint16_t test = pwm_get_counter(another_slice_num);
+        volatile uint16_t duration = pwm_get_counter(slice_num) * 42;
+        volatile uint16_t test = pwm_get_counter(slice_num);
+        volatile float distance = (test * 314) / (20000);
+        if (distance > 20)
+        {
+            distance = 20;
+        }
+
+        distance = 20 - distance;
+
+        volatile int percentage = (distance / 10) * 100;
+
+        set_progress(percentage);
     }
 
-    else if (events & GPIO_IRQ_LEVEL_LOW)
+    else if (events & GPIO_IRQ_EDGE_RISE)
     {
-        pwm_set_counter(another_slice_num, 0);
+        pwm_set_counter(slice_num, 0);
     }
-    */
+
     //    volatile uint16_t test = pwm_get_counter(another_slice_num);
     //    volatile float distance = (test * 314) / (20000);
     //    if (distance > 20)