question for 3 digit 7 segment display

Hello,
i'm new to arduino and it's language, i have made a program if i press a button it counts up on a 7 segment display, it counts from 0-9 and then returns to 0, the 7 segment display has 3 ground pins, 1 for each digit, so to control the other digits i need to rapidly connect and disconnect these ground pins, i have no idea how to program this though ?
how can i use the ground pins as a switch inside of the arduino ?, a automatic switch?
Thank you!