This week we are going to have a refactoring workshop to learn how to make our Arduino code cleaner and more organized.
For this workshop, we have proposed an exercise. We are going to start with an original code and the goal is to modify it to be better organized, while maintaining its functionality.
The original code is taken from the Open Source project Alexa-Controlled Thermostat with NodeMCU v3 and Raspberry Pi - Hackster.io. So take the opportunity to thank the author for sharing his work and project.
This project consists of a single code file, in which the temperature sensor is read, a rotary encoder is used, data is displayed on an LCD, and the Alexa API is used.
It is important to note that the exercise consists solely of refactoring the code. There is no need to add functionality or modify the way the original code performs its tasks. The only thing to do is to reorganize and clean it up, while maintaining its functionality.
You have this week to look at the code and refactor it. We remind you of the advice from this post on writing clean and organized code.
It is not necessary for you to have the hardware to do the exercise. We will assume that if the code compiles, it is sufficient (unless there is a circumstantial blunder).
After this week, we will share the results in our Discord community, where you will find more instructions and details about the exercise.