This fortune telling machine is a nod to the old Zoltar machines found at circuses and arcades. It's quick and easy to build and can accurately predict the future 50% of the time!
Modulo Gizmo Kit has everything you need for this project (except basic supplies like paper and tape).
About ModuloThis project is built using Modulo, a modular electronics system that makes it easy to assemble electronic devices. To learn more about Modulo in general, check out modulo.co.
Download and print out the Zoltar enclosure, pointer and servo mount. It's best to use thick paper. You could also glue copy paper to cardstock for better rigidity.
Cut out a holes for the knob and servo. You may wish to use an x-acto knife for this, though scissors will work in a pinch. Cut slits at the corners (on the short bold lines) and use tape to make a box.
Cut out the black square from the servo mount. Using tape, mount the servo so that the shaft barely protrudes through the top of the enclosure.
With the servo's shaft turned all the way counter-clockwise align the servo horn with the topmost answer line. Tape the pointer to the servo horn.
Connect the servo to the modulo controller with the orange signal wire next to the "0".
Put the knob through the hole and attach the knob cap. Your Zoltar is ready to be programmed!
We'll use the Arduino app to control Zoltar. If you haven't used Modulo with Arduino before, check out the getting started tutorials here. If you'd like to skip ahead and get Zoltar working quickly, you can just download the run the Zoltar.ino file below.
The code first includes the Modulo, Wire, and Servo header files and declares objects for the Servo and Knob.
#include "Modulo.h"
#include "Wire.h"
#include "Servo.h"
KnobModulo knob;
Servo servo;
Next, define a callback function that gets executed any time the knob is pressed. The function will move the servo in a sinusoidal pattern for 3 seconds. While it's moving, it will change the color of the knob in a rainbow pattern.
void onButtonPress(KnobModulo &k) {
# First get the current time in milliseconds.
long startTime = millis();
# Continually do this until 3 seconds (3000ms) past the start time
while (millis() < startTime + 3000) {
# Figure out the servo angle, which ranges between 0 and 180
# in a sinusoidal pattern based on the current time.
servo.write(90*(1 + sin(millis()/400.0)));
# Set the hue of the knob based on the current time too.
knob.setHSV((millis() % 500)/500.0, 1, 1);
}
}
The setup function attaches the Servo to pin 0 and registers the callback function.
void setup() {
servo.attach(0);
knob.setPositionChangeCallback(onPositionChanged);
knob.setButtonPressCallback(onButtonPress);
}
The loop function calls Modulo.loop() (so that button press events can be handled) and pulses the Knob's LED.
void loop() {
Modulo.loop();
knob.setHSV(0, 1, sin(millis()/1000.0));
}
Upload your code to the Modulo controller and your Zoltar is ready to predict the future!
Comments