Unfortunately, it is not possible to set a hard spending limit. This is discussed also in this question and in this one.
However AWS offers various other tools, such as budgets, for managing your costs.
Extensive documentation about cost management can be found at the following resource:
https://aws.amazon.com/aws-cost-management/
There is also a page about specifically how to avoid charges with AWS Free Tier: https://aws.amazon.com/premiumsupport/knowledge-center/free-tier-charges/
In general, I regularly get the feeling people overestimate the capabilities of the AWS free tier version. For any kind of production environment or meaningful computation you should expect actual charges to occur.
If it is just for learning purposes, make yourself familiar with what exactly the AWS Free Tier allows. Other than that, your budget is already a good way of monitoring your cost limit, also take a frequent look at your AWS Billing Dashboard.