In the example, values calculated by using the trigonometric function of the math library are visualized on the screen of CyberPi.

    This is a simple project. You can see that the values are calculated by the computer and displayed as graphics on the screen of CyberPi. It makes good use of the drawing feature of CyberPi (though you can draw the graphics on your computer).

    Or you can reverse the process, using a computer to visualize data collected by CyberPi. For example, you can display the result of an online vote of a class on the screen of a computer, or design a mobile app or cmputer client for CyberPi through Python programming.

    1. import os
    2. import sys
    3. from time import sleep
    4. import random
    5. import math
    6. import cyberpi
    7. # Display the phase difference between the sin and cos functions
    8. # Green indicates the cos function, and white indicates the sin function
    9. print("ready!")
    10. count = 0
    11. while True:
    12. val = int(math.sin(count / 2) * 50 + 50)
    13. cyberpi.display.set_brush(0,255,0)
    14. # Currently, only integers are valid, and so the values are changed into the int type
    15. cyberpi.linechart.add(int(val))
    16. val = int(math.cos(count / 2) * 50 + 50)
    17. cyberpi.display.set_brush(255,255,255)
    18. # Currently, only integers are valid, and so the values are changed into the int type
    19. cyberpi.linechart.add(int(val))
    20. # Set the drawing spacing of the line charts. Try to modify the spacing
    21. count += 1