Codecraft includes the ability to write programs for "sprites" - objects displayed on the Codecraft screen that can move and interact the mouse, keyboard, and with each other. Sprites can be used to create games and other user interfaces.
Consider the classic video arcade game, Pong.
(You can play a game of Pong in your browser at https://ponggame.io)
The sprites in Pong include:
2 paddles
ball
top and bottom walls
net
You could build Pong with Codecraft using physical inputs on your Arduino board.
Codecraft includes the "Device" area which we've been using to develop Arduino programs.
It also includes the "Stage" area for developing sprite programs.
Codecraft includes the "message" function to send information between the Device(Arduino) and the Stage(Sprites)
Here's an example to get you started:
Download this Codecraft project file [Arduino_Sprite_rotate.cdc] to your computer.
Then, open it with Codecraft (Files .... Open Local Projects).
Your project will include two programs, one for the Device(Arduino), and one for the Stage(sprite).
In Device, you'll need to click on Connect because this uses the Arduino USB serial connection for the broadcast function. Use the Serial Monitor to set the correct baud rate. In the Serial Monitor, the broadcast messages look like this:
broadcast(RDYvquF8SHHj1ezjru4g,-0.01)
In Stage, click on the flag button to start the program.
AnalogRead the value of the rotary potentiometer.The potentiometer value ranges from 0 to 1023.
Use map to map the potentiometer value to an angle in a complete circle, 0 to 360 degrees.
broadcast the angle to the Stage.
In a forever loop:
Set the "angle" variable to the received value of the message.
Change the angle of the sprint with point.
Here's another example, using the Grove Beginner Kit accelerometer to control the rotation of the sprite:
Arduino_Sprite_accelerometer.cdc
Here's a much more interesting sketch by Henry G, a student in the June 2025 Intro to Arudino class. It's based on the "Magic 8 Ball" toy that answers questions about the future!
[https://en.wikipedia.org/wiki/Magic_8_Ball]
[https://magic-8ball.com/]
Download this Codecraft project file 8 Ball Project.cdc and open in with Codecraft. Be sure to set the correct baud rate in the Serial Monitor so that the Arduino hardware messages broadcast to the CodeCraft "Stage" will be understood.