Applied Charles' method of writing to gpio