Code to sample and send