Duration: ~45 minutes Prerequisites: Level 1 or basic Python
Learn more about ImagiCharm | Project Gallery
Lesson 1: Programming Concepts
Learn how to animate pixels and create simple movement effects on your ImagiCharm. Practice using loops and functions for animation!
Activity 1: Variables and Expressions
led_count = 5
print(f"Number of LEDs: {led_count}")
Activity 2: Functions
def blink_led(times):
for i in range(times):
print(f"Blink {i+1}")
blink_led(3)
Activity 3: User Input
try:
name = input("Enter your name: ")
print(f"Hello, {name}!")
except Exception:
print("Input not supported in this environment.")
Activity 4: Simple Animation
import time
import sys
def animate_pixels():
colors = [(255,0,0), (0,255,0), (0,0,255)]
for color in colors:
sys.stdout.write(f"\rAnimating pixel: {color}")
sys.stdout.flush()
time.sleep(0.5)
print("\nAnimation complete!")
animate_pixels()
Combined Solutions & Animations
Variables and Expressions
led_count = 5
print(f"Number of LEDs: {led_count}")
Function to Blink LED
def blink_led(times):
for i in range(times):
print(f"Blink {i+1}")
blink_led(3)
User Input
try:
name = input("Enter your name: ")
print(f"Hello, {name}!")
except Exception:
print("Input not supported in this environment.")
Simple Animation
import time
import sys
def animate_pixels():
colors = [(255,0,0), (0,255,0), (0,0,255)]
for color in colors:
sys.stdout.write(f"\rAnimating pixel: {color}")
sys.stdout.flush()
time.sleep(0.5)
print("\nAnimation complete!")
animate_pixels()
Project Info
- Device: ImagiCharm
- Language: Python
- Skills: Variables, functions, user input, animation
- External Resources:
Next: Level 3 – Rainbow Glow & Patterns Previous: Level 1 – Moving Pixels