Step-by-Step Coding Tutorials

Let’s get ready to code your Solar Panel project. To follow the coding tutorial on Makecode, click the Start Coding button below.


Open Coding

If you’d like to try coding your Solar Panel without following a tutorial, you can code openly in the traditional Makecode workspace by clicking the link below.

Here’s a brief description to help you on your open coding journey:

Objective: Move the solar panel using the positional servo motor from east to west in small increments to search for sunlight. When sufficient sunlight is detected by the solar sensor, have the solar panel stop in that position for as long as optimal sunlight is present.

Coding Description: Imagine a solar panel setup that can move to catch the most sunlight. This code controls that movement. It starts with the solar panels facing left (-90 degrees). It keeps checking how much light the panels are getting. If they’re getting a lot (more than 90), it shows a diamond icon to signal it’s in a good position, and the movement is stopped. But if it’s not getting enough light, it shows a target icon and starts moving the panels to the right by 10 degrees each time. If the panels move too far to the right (more than 90 degrees), they’re brought back to the leftmost position. The code then waits a little bit to allow the panels to adjust before checking the light again. It’s like the solar panels have their own way of finding the best spot to catch sunlight and stay efficient.