Hour of Code:
Programming in Pencil Code
coding events with Pencil Code
Welcome to our astronomical Hour of Code event! Here are the
materials you will need to host a successful hour using
Before you start, make sure you can set up an account and save work
under an account. Make sure your school firewall does not block *.pencilcode.net.
For kids to save their work, they will need to have access to their own
domain under pencilcode.net.
Color, Images, and Astronomy
Click here to begin the video activity.
Computing does not end with computers!
So this year we have an activity that shows
how astronomers use computers to create
images and understand their data.
This activity is appropriate for
4th through 12th grade students, with
no prior coding experience necessary.
Skip to specific projects here:
- recolor - try creating a
color by stimulating your own red, green, and blue
eye cells with an intensity between 0 and 255.
This is how computers create color.
- scene - explore filters
and color-shifting using a coloring function that
maps input RGB colors to an output RGB colors.
- flowers - mash up two
images using a coloring function to mix red,
green, and blue light from multiple images.
- supernova - see how astronomers combine different images to create a single colored image of the leftovers from a star exploding (input data).
- starforming -
explore a deep six-wavelength stack of astronomy
images, and create your own unique
never-before-published RGB image of
a star-forming region (input data).
- keplersnova - In 1604 a star suddenly
exploded and became the brightest object in the sky.
Examine the remnants of the supernova observed by
Kepler in the 17th century (input data).
- blackhole - See x-ray data revealing
a supermassive black hole at the center of a galaxy
Tell us what you think!
Submit a survey response.
This activity was created by
volunteers August Muench, astronomer
for the American
Astronomical Society, Kim Arcand,
visualization lead for
Chandra X-ray Observatory, and Sydney
Pickens and Matthew Dawson, both computer
science educators with
CS First. Thank you all!
Learn how to make your own program to draw line art,
and save it on your own website. Good for all ages.
The language used in Pencil Code is CoffeeScript. Background
on the CoffeeScript language can be found in several good books
online (for example
Geometry and Coding: Angles and Arcs
Use Pencil Code to explore math facts about angles, arcs, and
polygons. Good for middle school and high school
Computational Thinking: Hangman
A one-to-two hour lesson introducing the basics of programming
with Pencil Code by building one detailed project from end-to-end.
Good for high school students and advanced middle school
students who are motivated to take on a coding challenge.
- Memory and naming
- Computer arithmetic
- Using functions
- Simple graphics
- How to make a program
- Input and output
- Loops and choices
- Delays and synchronization
- Connecting to the internet
There are other ways to use Pencil Code
at coding events.
- activity.pencilcode.net - Printable activities.
This page has several classroom-tested
printable activites, good for events with
teachers, or events where you want to give
participants choices by letting them pick a
- gym.pencilcode.net - The Pencil Code Gym.
These fully-online activites work well for
events with walk-up participation with no
preparation. These self-teaching activities
are designed with a wide range of activities
for all levels of beginners.
If planning in advance, the Pencil Code Book can provide the best of both worlds: a choice of 100 activities, but readable in a friendly paperback form.
Thank you for your participation!