Edinburgh is blessed with three castles, not just the iconic Edinburgh. However, if you want to venture further from the city then I would recommend Stirling Castle for a history hit.
This region has the most castles in all of Scotland, the region is perfect to explore on a road trip and it is an easy day trip from either Aberdeen or Inverness.