Added function to convert index to gpio pin