Depending on you approach and timing:
NH boarder - Coast Road - Rt 1A, B C Runs along side the ocean. Seabrook to Portsmouth. If a heavy summer beach day, skip around Hampton Beach. Portsmouth is a great Restaurant and walking town.
Maine Coast - Kittery Rt 103 to York, Right on Rt 1A to York Beach and lighthouse. Shore Road to just below Kennebunkport. Possible traffic jam to center. Can turn off to coastal road to go around town and onto Rt 9. In Arundel, Bentley's Saloon - best Biker bar in New England. Jump up to Old Orchard Beach and The Pier. Jump up to Portsmouth. Old Port area. Again, great restaurant area.
That gets you to the ferry. But, you might want to consider driving one way, ferry the other.
This would allow you to stop in Freeport LL Beans and other outlets, Bar Harbor - bridge with elevator to top providing 4 state view, Rockland - Lobster town, Roosevelt's Campobello Island - history, St Andrews, St Johns - Reversing Tides, ferry over to Digby. Scallops !!!!
Go over the top trail. Aircraft Museum, then Halifax ! Casino, old fort, harbor tours, outstanding brewery tour, roof top fire pit bars. Awesome city.
Return on the Lighthouse Trail. Lots of scenic stops. Great place to stay, but pricey in season, Quarterdeck. Has a gourmet restaurant too !
Yarmouth for ferry. Don't allow too much time. Town has not fared to well with the ferry - no ferry interruptions.