Make a Mood Tracker
Abstract
How do you feel right now? Do you remember how you felt a few hours ago? How about yesterday or last Wednesday? What if you could track your emotions throughout the day and use this information to help improve your mood and well-being? In this science project, you will program a simple, pocket-sized device that you can carry around with you to log your feelings whenever you want or on a specific schedule.
Summary
None
micro:bit board required, see Materials section for details
No issues
Objective
Program and test your own mood tracking device.
Introduction
Have you ever kept a paper-and-pencil journal about your thoughts and feelings? Have you used a life-tracking app on a smartphone, website, or computer? How did your mood or emotions change throughout the day or week? Did you notice any patterns or trends? Were your moods connected to specific events in your life? For example, maybe you felt excited on the day of a friend's birthday party and grumpy on a Monday morning when you had to go back to school. Keeping track of your moods can help you think about why you feel the way you do and might help you identify ways to improve your overall well-being!
In this project, you will program your own simple mood tracker using a device called a micro:bit. A micro:bit is a little programmable board with buttons and a grid of lights called LEDs. You can use the LEDs to display scrolling text or simple drawings like happy and sad faces (Figure 1). The micro:bit can also do data logging, which means it can store data that you can look at later. Data can be something physical, like the temperature or sound level in a room, but it can also represent something emotional. For example, you could rate your moods on a scale of 1 to 3, where 1 = sad, 2 = OK, and 3 = happy (you could use a larger number scale, too). Every time you rate your mood, you create a data point that has a timestamp, which tells you when the data was recorded.
Data logging can allow you to do some simple data analysis of your moods. You might decide to check in with yourself and give a mood rating at a few specific times of the day (like 9AM, 12PM, 6PM, and before bed). When you look at your data later, you might notice patterns. If your mood numbers trend low, for example, at noon on weekdays, maybe there is a reason? Maybe you need to adjust your eating schedule? Maybe you need to work in a short walk or break? Or maybe you really just do not like whatever class you have at that time. Sometimes, our moods are easy to match to external factors!
Since the micro:bit is pocket-sized, you can carry it around with you to keep track of your feelings throughout the day. You might keep it in a pouch attached to your backpack or keys. You could even rig a holder to wear your micro:bit mood tracker on a lanyard. Nothing says biotech can't be an accessory! At the end of the day (or week), you can upload the data to your computer. You can look at the data to see how your feelings changed throughout the day, and think about what events or factors might have caused those changes. If you look at your data weekly or monthly, you may be able to spot bigger trends and even identify lifestyle or health changes that might help improve your mood overall. The procedure of this project will show you how to get started programming a basic mood tracker, but you can customize how it works using the micro:bit's easy programming interface. You might even want to program a schedule so that the device prompts you at various points in the day, maybe with a beep, to stop, think about how you feel, and enter your rating. It just takes a second to check in with yourself, but the benefits can be huge!
Terms and Concepts
- micro:bit
- LED
- Data logging
- Timestamp
Questions
- What are some different ways you could use a journal, app, or device to track your moods throughout the day?
- What are the advantages and disadvantages of each approach? For example, which method is easiest to carry around with you all day? Which method is better if you want to reduce screen time?
Bibliography
- Micro:bit Educational Foundation (n.d.). Getting Started. Retrieved May 1st, 2025
- Micro:bit Educational Foundation (n.d.). Data Logging Overview. Retrieved May 1st, 2025
Materials and Equipment
- micro:bit Go Bundle. This kit contains everything you will need to get started working with micro:bit:
- micro:bit board
- micro-USB cable
- 2xAAA battery holder
- AAA batteries (2)
- Computer with internet access and USB port
Experimental Procedure
- If this is your first time using a micro:bit, follow the Getting Started instructions on the micro:bit website to learn how to use your micro:bit and how to connect it to your computer.
- Decide what programming language you will use for your micro:bit:
- If you are new to coding, we recommend using Microsoft MakeCode to program your micro:bit. MakeCode is a graphical programming language that lets you make computer programs using colored blocks of code instead of a text editor. The example code in this procedure uses MakeCode. We recommend following a few of the MakeCode tutorials before starting your mood tracker project.
- You can also program your micro:bit in Python, JavaScript, or Scratch. You may prefer this approach if you already have programming experience in one of these languages. See the Let's Code page for more details.
- Start a new MakeCode program.
- Click
+Extensions
in the blocks menu and click thedatalogger
extension to add the data logging blocks to your blocks menu. - Make the program shown in Figure 2. Here is how the program works:
- The
on start
block sets the program up so it is ready for data logging.- It creates an "emotion" column to log your mood. The timestamp for each entry will automatically be logged.
- For now, we will set the units for the timestamp value to seconds. This will allow you to quickly test your program to confirm that it works. When using the program to track your mood throughout the day, you will probably want to change the units to hours.
- Note: the timestamp is measured as elapsed time since the program started running or the micro:bit last powered on or reset. If you want to log your mood at the same time(s) every day, you will need to reset the micro:bit at the same time each morning.
- The
on button A pressed
block cycles the LED display through three moods: sad, OK (meaning not really sad or happy), and happy. Pressing the button a fourth time will turn the LEDs off to save battery power. - The
on button B pressed
block logs a data point for the mood that is currently displayed.- It uses the value of a variable called
emotion
, where 1 = sad, 2 = OK, and 3 = happy. - If you press button B while the LED screen is blank (
emotion
= 0), then it does not log any data. - After logging the data, the screen displays a check mark for one second, then goes blank again.
- It uses the value of a variable called
- The
on button A+B pressed
block deletes the stored data. You can also delete the data by downloading a new program to your micro:bit.
- The
- Make sure your micro:bit is plugged into your computer with a USB cable. Then click the
Download
button to send the program to your micro:bit. - Practice using the program. Press the A button to cycle through the different moods. Press the B button to log the emotion. You do not have to log your real moods for now. You are just testing the program to make sure it works. Be careful not to press the A and B buttons at the same time until after you have uploaded your data to your computer, or you will lose all of your data!
- When plugged into your computer, the micro:bit works like a USB flash drive. Open the micro:bit folder to see the files on it and double-click MY_DATA to view your data in a web browser. Ask an adult or see the instructions on the micro:bit data logging page if you need help with this part.
- You should see a table with one column for time in seconds and one column for the value of the
emotion
variable.- If you click the
Visual preview
button, you can see a graph of your data (Figure 3). - Click the
Download
button to download a comma-separated values (csv) file that contains your data. You can open your csv file in a spreadsheet program like Microsoft Excel or Google Sheets.
- If you click the
- Look at the graph in Figure 3. Can you tell what happened based on the graph? In this example data, it looks like the person was happy, then something happened to make them sad, and then, after a little while, they felt better again.
- If you want, you can add a reminder to log your mood after a certain amount of time. You can do this using the
every 500 ms
block underLoops
.- This block will make the code inside it run at a specified interval. Try putting something from the
Music
menu inside the block to make the micro:bit play a sound or melody as a reminder. - This block uses milliseconds (ms) to measure time. There are 1,000 milliseconds in one second, so there are 60,000 milliseconds in one minute, and 3,600,000 milliseconds in one hour! So, for example, to set a reminder every 3 hours, you would change the value to 3 × 3,600,000 = 10,800,000 milliseconds.
- Remember that the micro:bit measures time from when it was last powered on or reset. So, to log your mood at the same times every day, you would need to power on or reset the micro:bit at the same time every morning. For example, if you set a reminder for every 3 hours and reset the micro:bit at 9:00 AM, then the reminders will go off at 12:00 PM (noon), 3:00 PM, 6:00 PM, and so on (you will want to unplug the battery pack overnight so the micro:bit does not wake you up at 3AM!).
- This block will make the code inside it run at a specified interval. Try putting something from the
- Once you have tested your program and have it working, you are ready to track your moods!
- Remember to change the units for the
set timestamp
block to hours instead of seconds. Re-download the program. - Unplug your micro:bit from your computer and plug in the battery pack.
- Carry your micro:bit around with you throughout the day and use it to log your moods.
- At the end of the day, reconnect your micro:bit to your computer and open the MY_DATA file.
- How did your mood change throughout the day? Do you remember what caused those feelings?
- Remember to change the units for the
- Repeat this process for at least a few more days (preferably one week or more).
- Do you notice any trends or consistent patterns in your mood?
- If so, what do you think could be causing them? Can you make any changes to improve your mood?
- There are many other things you can do to change or improve your mood tracker. See the Variations section for some suggestions.
Ask an Expert
Variations
- Can you change your code to let the user select from a wider range of moods, for example, using a scale of 1-5 instead of a scale of 1-3? What else could you display on the LED screen instead of smiley and sad faces? Check out the options under
Basic
in the micro:bit menu to see what you can display on the LEDs. - The micro:bit has other inputs, called sensors, besides buttons. You can read more about them on the micro:bit sensors page. Can you write a program that uses other inputs besides the buttons? This could be an especially good option for small children who have trouble pushing the tiny buttons. For example, can you make it so they can shake the micro:bit when they're mad (using the accelerometer sensor), or cover it up to block light from hitting it when they're sad (using the light sensor)?
Careers
If you like this project, you might enjoy exploring these related careers:
Related Links
- Science Fair Project Guide
- Other Ideas Like This
- Human Behavior Project Ideas
- Computer Science Project Ideas
- My Favorites
- Make a Communication Aid to Help People Show Their Feelings