Skip to content
Parallax Learn

Parallax Learn

  • Welcome
  • Tutorials
        • Tutorial Series head tag

          Tutorial Series
        • Tutorial Series

          The special, classroom-ready series pages are organized collections of tutorials for our most popular hardware and/or languages. The tutorials for each topic are conveniently accessible from a single page, shown in the order it is recommended that they be completed.
        • Robotics Series Head tag

          Robotics Series
        • Robotics Series

          • Artificial Intelligence
          • Cybersecurity: Radio Data tutorialCybersecurity
          • cyber:bot + Python
          • cyber:bot + MakeCode
          • Boe-Bot Tutorial SeriesBoe-Bot
          • Arduino Shield-Bot
          • ActivityBot with C TutorialsActivityBot + C
          • ActivityBot with BlocklyProp Tutorial SeriesActivityBot + BlocklyProp
          • Scribbler 3 Tutorial SeriesScribbler 3
        • Electronics & Programming Series Head tag

          Electronics & Programming Series
          • BS2 Board of Education Tutorial SeriesBS2 Board of Education
          • Propeller C-Language BasicsPropeller C Basics
          • FLiP Try-It Kit C Tutorial SeriesFLiP Try-It Kit + C
          • FLiP Try-It Kit BlocklyProp TutorialsFLiP Try-It Kit + BlocklyProp
          • Badge WX Tutorial SeriesBadge WX
          • Propeller BlocklyProp Basics and ProjectsPropeller BlocklyProp Basics
          • View All Tutorial Series »
        • Browse Tutorials
        • Browse Tutorials

          Individual tutorials sorted by robot or kit, and language.
        • By Robot or Kit
          • ActivityBot
          • SumoBot WX
          • Boe-Bot
          • Shield-Bot
          • cyber:bot
          • Badge WX
          • ELEV-8
          • ARLO
        • By Language
        • By Language

          • Propeller C
          • Arduino
          • BlocklyProp
          • PBASIC
          • Python
          • MakeCode
          • View All Tutorials »
  • Educators
  • Reference
  • Downloads
  • Home
  • All Courses
  • AI for Simple Python Scripts

AI for Simple Python Scripts

Asking for More

Try This: Asking for More Features

User
Could you update that script to display a beating heart?  Maybe at 60 beats per minute?

ChatGPT
Certainly! You can create a beating heart animation by alternating between a filled heart and an empty heart at a regular interval. Here’s an example program that displays a beating heart at 60 beats per minute:

from microbit import *
import time

heart_full = Image("09090:99999:99999:09990:00900")
heart_empty = Image("00000:09990:09990:00900:00000")

while True:
    display.show(heart_full)
    time.sleep(0.5)  # Display the full heart for 0.5 seconds
    display.show(heart_empty)
    time.sleep(0.5)  # Display the empty heart for 0.5 seconds

This program defines two images, heart_full and heart_empty, representing a filled and an empty heart, respectively. Inside the loop, it alternately displays the full and empty hearts with a delay of 0.5 seconds between each.

Feel free to adjust the sleep times or customize the animation to suit your preferences!

  • Enter the script into the micro:bit Python Editor, and name it AI_heart_more.
  • Run the script by clicking the Send to micro:bit button.
  • Did it work as ChatGPT described? In what ways yes, in what ways no?
  • Could it have done a better job?  How? For example, could it have used pre-existing Image heart shapes instead of making up its own?

 


Printer-friendly version
First AI Script
Prev
Asking for Better
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

About | Terms of Use | Feedback: learn@parallax.com | Copyright©Parallax Inc. 2024

© 2025 Parallax Learn • Built with GeneratePress