If it's motivation for a personal project, that's far more personal and the first thing is to make sure that the rest of your life is together to give you to the environment you need to get your personal projects done. I'm working on my second book right now, my first did really well but I've lost all the drive to do anything with the second one. The first one burnt me out completely, so I'm trying put things around me that will get me in the right frame of mind and wait for the spark of creativity to light and then I can get it finished.
One thing I definitely did wrong was not taking a 4-6month break after college to really decide what I wanted to do and de-stress. After leaving a FAANG about two years after graduation I did this out of desperation and cannot describe the positive effect on my work ethic and mental state after basically not doing anything productive for 5-6months.
This might be a common trait with those who have ADHD but I usually find that the only way to de-stress is to simply remove all forms of taxing sensory input or work for at least 3-4 weeks.
Talking to my close friends helps me retrospect what made me loose motivation in what I started.
Sometimes just by pulling out all my will power to do same non motivated task for 20mins brings back all the momentum needed to get me going.
When there is a task that you are faced with that you don't like, attempt to rephrase how you look at it. Instead of saying, "I don't want to $foo," say, "I want/need to do $foo so I can $bar." When you approach tasks by looking at the benefits you appreciate, it becomes easier to take the next step in that task. Or it might reveal that you shouldn't be doing a given task!
The less motivated I am, the bigger that paycheck needs to be.