Java is a powerful language that’s been popular in education for many years. Like all programming languages, it’s often helpful for learners to work with images. The visual feedback that images give can be more engaging and more intuitive than text alone. Yet, many instructors don’t know that you can use Java’s built-in libraries to easily make your own images!
In this quick post I’ll use the Java Trinket to create a simple image, a version of the Trinket logo. The code is based on an excellent example by Byron Kiourtzoglou over on Java Code Geeks.
In this example, we make both a png and a jpeg from the same Graphics2d object. Check it out:
I’m excited to finally be able to show off a special project we’ve been working on with our friends at the Raspberry Pi Foundation for the past few months: a 3D Astro Pi emulator! Hundreds of thousands of students and teachers have used Trinket to run Python, Java, and HTML in their classrooms. Now, thanks to the Raspberry Pi Foundation, anyone can code a virtual 3D Astro Pi with Python. Check it out:
The Sense Hat is a simple device that attaches to the low-cost Raspberry Pi computer and allows easy physical computing – writing programs that interact with the real world.
If you’re not familiar with the Astro Pi project, you’re in for a treat. There are two Raspberry Pi computers (named Izzy and Ed) up on the International Space station and kids around the world submit code they’ve written for a chance to have it run in space! Ed has a Raspberry Pi camera module attached to him, and Izzy has a Sense Hat attached, letting students and event he astronauts themselves write programs to monitor the environment on the station, measure gravitational fields, and display information via the color LEDs. Learn more about Astro Pi here.
Here’s what Izzy, the Sense Hat Astro Pi looks like up in space with British ESA Astronaut Tim Peake:
Dr. Aaron Titus is Associate Professor of Physics and Chair at High Point University. He has been using and creating technology to teach Physics since the late 90s. I’ve been fortunate to know Aaron for many of those years, originally through our mutual work on WebAssign and now with Trinket and GlowScript. In this interview, Aaron talks about specific tools he uses in his classroom, how to get educators and students alike interested in using coding for Physics, and more. Enjoy and definitely check out some of his links!
You can find other interviews in our interview series here.
We’ve been working most of the summer on an exiting new project with the Raspberry Pi Foundation, one of the world’s leading coding education charities. Together we built an in-browser emulator for the Sense HAT device, which adds sensors, gyroscopes, and color LEDs to their inexpensive Raspberry Pi computers. Here’s what the finished product looks like:
Here’s what the Sense HAT and Raspberry Pi look like in real life. The Raspberry Foundation’s designers provided us with the cool image that we modified to use in the emulator- not bad, huh?
What’s The Sense HAT Do?
Like all Raspberry Pi devices, the Sense HAT is cool enough to have developed a huge base of hobbyists who love it but really shines for students learning to code in the classroom. The Sense HAT is one of the best devices for connecting code to the real world by allowing students to see their code read temperature and make LEDs light up with relatively little overhead or boilerplate. Raspberry Pi wanted to build an in-browser emulator to bring this neat tool to as many students as they could around the world. We were excited and honored when they reached out to us about submitting a proposal for the project this past Spring.
Why Raspberry Pi Picked Us
If you’re a reader of this blog you probably know that Trinket is all about quick, easy, in-browser coding. Luckily for us, the Raspberry Pi folks had heard about us too. They recently merged with another amazing UK-based charity, Code Club, who’s been using embedded trinkets in their free HTML and CSS projects for about two years now. The Code Club staff made sure that the Sense HAT project team knew about us and the rest, as they say, is history.
To Space – And Beyond!
So what are the Foundation’s plans for the new emulator? If you haven’t hear about it, the Foundation has been running one of the coolest coding projects we’ve ever seen, called Astro Pi. They sent two Raspberry Pi computers up to the International Space Station with British ESA astronaut Tim Peake in 2015. This Spring, they held several contests for students to submit Sense HAT programs for a chance to have Tim run them in Space. Amazing! The new emulator will allow thousands more students to participate in upcoming contests as Raspberry Pi looks to expand it to other space programs around the world.
Doing More With The Sense HAT
But regardless of whether you’re a student with an astronaut on the ISS, the new emulator will let you experience the fun of a Sense HAT equipped Raspberry Pi for free. And while students in Science class will likely be writing programs using the environmental sensors, the Sense HAT can do a whole lot more. For instance, here’s a clone of the popular Flappy Bird game:
To play, make sure the Sense HAT window is active by clicking on it, then use the ‘up’ key to fly your bird with the virtual joystick. How many points can you get?
The new technology is available from all of our Python trinkets- just import sense_hat and you’re off! To see more example programs, check out our new demo page for the project. And if you already own a Sense HAT, a special Download button in the left-hand menu will let you download everything you need to run these programs on your Pi.
We can’t wait to see what our awesome users come up with! If you write a cool program, tweet it to @trinketapp and @Raspberry_Pi for a chance to get featured!
A Little Help From Our Friends
A project like this is the work of many hands, so I’ll end a few words of thanks. Raspberry Pi Team Members Dave Honnes, Ben Nuttall, Helen Lynn, Philip Colligan, Rik Cross, and the others who worked behind the scenes on this project made it a success. Thanks to all of the awesome beta testers who tested the emulator as we built it and provided helpful suggestions. Dave Jones did amazing work with the sense_hat module’s new SenseStick API that we were able to implement in Skulpt. Speaking of Skulpt, open source developers Michael Ebert and Albert Jan Nijburg were a key part of the Trinket team for the project. Their expertise and diligence really shows clearly in the final product. The rest of the great Skulpt development community continues to make improvements to Skulpt, which is a key part of our in-browser Python interpreter, and we’re extremely grateful for their efforts. Finally, thank YOU, our users, for teaching and learning code using our tools every day. Together we’re making the world a better, more hackable place!
Youngseok Lee is a Professor in the Department of Computer Engineering at Chungnam National University in Korea. He teaches Python for data and network and analysis to college freshmen and recently translated one of our Hour of Python lessons into Korean! We had the opportunity to learn a little more about Youngseok in the interview below. Check out his thoughts about how powerful Python is and why it’s a great language to learn.
You can find other interviews in our interview series here.