7 segment LED

So, where's your problem? Your code works, and you can wrap it up into a nice, small function that you call from your main program.