Code for scratch_gpio_handler