Skyhawk 172/Cutlass 172
Flight Crew Commercial; Flight Crew Flight Instructor; Flight Crew Multiengine; Flight Crew Instrument
Flight Crew Last 90 Days 32.5; Flight Crew Total 318.4; Flight Crew Type 277.7
Distraction; Situational Awareness
Airspace Violation All Types; Deviation - Track / Heading All Types; Deviation / Discrepancy - Procedural Published Material / Policy
General None Reported / Taken
Human Factors
I was taking a student to ZZZ for a checkride. I was the Pilot Flying so he could relax a bit before the ride. Our route of flight was direct ZZZZZ direct ZZZ. We departed ZZZ1 at roughly XA:00am local time. After departing the area to the north I went direct ZZZZZ that way we will stay clear of all parts of the Bravo at 7;500 feet. The GPS looked good; ZZZZZ was in the right spot; the course looked good; so we continued direct. We arrived at out destination about an hour and a half later. Flight on the way back was the same route. Upon looking at the flight in ForeFlight; some time later; I had discovered I did not fly direct ZZZZZ. The GPS showed ZZZZZ; but we were far from it. When we were approximately 3.5 NM to the north east of [track] I was within 200 feet of the Bravo laterally at 7;500 feet next to the 7000/1;2000 foot shelf. After thinking about how this could have happened I came to the conclusion that the OBS button was hit sometime before I hit direct ZZZZZ. I had not noticed the OBS was on; and taking us on a different route. This entire situation could have been avoided if I would have done one of a few things. First; I could have seen the OBS was on. Second; I should have been with flight following. They would have helped us out to get squared away. Third; if I had foreflight open I could have seen we were not on our planed route. From this experience I will be with flight following when that close to the bravo; and I will always be checking my surroundings more no matter the flight.
C172 instructor was pilot flying and reported not following published procedures; causing a track deviation.