# Simple animation on Stellar Unicorn

**URL:** <https://forums.pimoroni.com/t/simple-animation-on-stellar-unicorn/24619>\
**Category:** Support\
**Created:** [April 9, 2024, 8:42pm UTC](https://forums.pimoroni.com/t/simple-animation-on-stellar-unicorn/24619 "2024-04-09T20:42:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Crownforakid](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/crownforakid/32/10760_2.png) [@Crownforakid](https://forums.pimoroni.com/u/Crownforakid)\
**Post date:** [April 9, 2024, 8:42pm UTC](https://forums.pimoroni.com/t/simple-animation-on-stellar-unicorn/24619/1 "2024-04-09T20:42:41Z")

</div>

I want to get 2 images to swap back and forth on my Stellar Unicorn. I have a jpg image already showing on the unicorn but want it to show another image quickly. Is there code I can use to make it that after 0.5 seconds the image changes, I’m very new to all this! Thank you :)

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [April 9, 2024, 8:52pm UTC](https://forums.pimoroni.com/t/simple-animation-on-stellar-unicorn/24619/2 "2024-04-09T20:52:30Z")

</div>

Could you post the code you have so far please?

---

<div class="post-metadata">

**Author:** ![Crownforakid](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/crownforakid/32/10760_2.png) [@Crownforakid](https://forums.pimoroni.com/u/Crownforakid)\
**Post date:** [April 10, 2024, 9:31am UTC](https://forums.pimoroni.com/t/simple-animation-on-stellar-unicorn/24619/3 "2024-04-10T09:31:58Z")

</div>

```auto
from picographics import PicoGraphics, DISPLAY_STELLAR_UNICORN as DISPLAY
from stellar import StellarUnicorn
import jpegdec

stellar = StellarUnicorn()
graphics = PicoGraphics(DISPLAY)

# Create a new JPEG decoder for our PicoGraphics
j = jpegdec.JPEG(graphics)

# Open the JPEG file
j.open_file("pee.jpg")

# Decode the JPEG
j.decode(0, 0, jpegdec.JPEG_SCALE_FULL)

# Display the result
stellar.update(graphics)

```

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [April 10, 2024, 11:31am UTC](https://forums.pimoroni.com/t/simple-animation-on-stellar-unicorn/24619/4 "2024-04-10T11:31:06Z")

</div>

Something like this may work? Worth a try anyway, I just quickly did it up.

```auto
import jpegdec
import time

stellar = StellarUnicorn()
graphics = PicoGraphics(DISPLAY)

# Create a new JPEG decoder for our PicoGraphics
j = jpegdec.JPEG(graphics)

while True:
    # Open the JPEG file
    j.open_file("pee.jpg")

    # Decode the JPEG
    j.decode(0, 0, jpegdec.JPEG_SCALE_FULL)

    # Display the result
    stellar.update(graphics)
    
    time.sleep(0.5)
    
    # Open the JPEG file
    j.open_file("other.jpg")

    # Decode the JPEG
    j.decode(0, 0, jpegdec.JPEG_SCALE_FULL)

    # Display the result
    stellar.update(graphics)
    
    time.sleep(0.5)

```

---

<div class="post-metadata">

**Author:** ![Crownforakid](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/crownforakid/32/10760_2.png) [@Crownforakid](https://forums.pimoroni.com/u/Crownforakid)\
**Post date:** [April 11, 2024, 8:46am UTC](https://forums.pimoroni.com/t/simple-animation-on-stellar-unicorn/24619/5 "2024-04-11T08:46:46Z")

</div>

Thank you I’ll give that a go now and see if I can get that working :)

---

<div class="post-metadata">

**Author:** ![Crownforakid](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/crownforakid/32/10760_2.png) [@Crownforakid](https://forums.pimoroni.com/u/Crownforakid)\
**Post date:** [April 11, 2024, 8:49am UTC](https://forums.pimoroni.com/t/simple-animation-on-stellar-unicorn/24619/6 "2024-04-11T08:49:13Z")

</div>

Thank you that works perfectly, I’ll post a quick video in a bit :D
