Client Project
IDeATe Minor Display by the Dewberries: Final Documentation
By the Dewberries (Maya, Selina, Tommy) : Final Documentation
By the Dewberries (Maya, Selina, Tommy) : Final Documentation
For this project in CMU's 60-223: Introduction to Physical Computing, we were tasked with helping a campus client improve an aspect of their daily work. Our client, Ryan, is the Academic Coordinator at IDeATe, who helps maintain the shared common space and foster a sense of community among students. We identified an opportunity to redesign the existing IDeATe minor information display into a more interactive experience that encourages students to explore the programs while bringing more activity into the space.
2. What we Built
The interactive minor display transforms a previously static and dull display into something more engaging and attention grabbing. A waving Scotty with blinking eyes draws people's attention while the card slots gradually move forward when someone walks by, encouraging interaction. To make the experience even more inviting, a compartment for candy and stickers is incorporated at the bottom of the display, which can be detached.
Storyboard of a idealized use case- a simple information display into a playful interaction that sparks curiosity, encourages small moments of engagement, and brings students together in the IDeATe. The usage story here is that a user walking through the library activates the motion sensors activating the card display. Scotty waves, the cards move, and the candy catches the user's eye making it engaging for them and enticing to use. The user will take a piece of candy, browse the cards being displayed to them, and possibly come back again to check out more minors and hang out in the IDeATe space which seems even more engaging and welcoming with this display.
Overall image of our display
Close up shot of a hand reaching toward the display, triggering the sensor to detect its presence and lift the card slot for easy access.
Close up shot of the Scotty figure at the top of the display, featuring blinking eyes and a waving arm to attract students’ attention.
Close-up of the removable back of the display, with a wide cut-out hole to make the breadboard and Arduino Mega accessible.
Close-up of the candy trough with dividers for stability as well as categorizing goodies.
As a hand passes over the sensor, the cards lift in a wave-like form, ready for you to grab one.
3. How we got here (prototype and process)
Overall, the interview went well and helped us better understand Ryan's role at IDeATe and the challenges he faces. We initially focused on his daily responsibilities, such as managing space requests, checking student information, and communicating with different groups. As the conversation progressed, we learned that one of his favorite parts of the job is hosting and bringing together students from different parts of campus. This helped us shift our focus from simply improving an administrative task to creating something that could make the IDeATe common space more engaging and welcoming.
However if we were to conduct the interview again, I think we would ask more specific follow up questions about how students currently use the common space and interact with the existing minor information displays or even observe and how passerbys interact with the display ourselves. This would have helped us identify opportunities for our design earlier and better understand how students might interact with it.
Our biggest takeaway was that Ryan values building a sense of community at IDeATe. Beyond his administrative responsibilities, he wants the common space to become somewhere students actually want to spend time. Another important takeaway is that he described himself as a maximalist who enjoys collecting little objects and displaying them, which was also reflected in how his office was decorated. Seeing his space gave us a better sense of his personality and aesthetic preferences, which we wanted to incorporate in our design. During the interview, we discussed several potential directions, including an in/out board, a suggestion box, games, and an IDeATe minor card dispenser. We were particularly interested in the card dispenser because it had a lot of potential in introducing a playful element to the space.
Ryan giving us a tour of his office during the interview, helping us better understand his aesthetic preferences and maximalist personality through his collection of objects and decorations.
During our interview, Ryan also showed us the existing IDeATe minor information display, which helped us identify areas for improvement and opportunities to make it better.
The single card dispenser prototype sought to answer the question of how we could dispense/present the card to the users in an IDeATe-esque, physical-computy way. This was created by using a button to control a motor with a rubber wheel that used its grip to pull out a card.
Video 1: sensor-lifting mechanism prototype. Video 2: hobby servo moving the card holder.
The sensor-lifting mechanism was made to see if we could create a mechanism that presents the card, is not prone to mechanical failure, and could be engaging for the user. It has a sloped design with a laser-distance sensor controlling a basic servo in the back which has a popsicle stick arm.
The prototype of the exterior was made to test the design's portability, scale to hold all the cards, and whether its visual language could capture a user's attention. The prototype of the candy slide was made to test whether we could come up with a mechanism to dispense one piece of candy at a time consistently with little mechanical hiccup. It was originally going to work with a rotating cup on the bottom that dispensed the candy, like a gumball machine.
The prototypes sought to answer questions about the different facets of our design and Ryan's requests. For one, we wanted to know how to deliver the cards to the user.
Prototype 1 had a rubber wheel on the bottom that would shoot the bottom card out one at a time via gravity and friction. The only issue with this is that, because it was highly mechanical and gravity-fed, the number of cards in the stack had a great effect on its success. Too many cards made it too heavy to dispense one card at a time. Too few cards made multiple shoot out or miss the exit slot because its lightness caused it to angle up. It would only work with the perfect amount of cards, around 15. Professor Zach then urged us to go with a less mechanical, more consistent design that still caught the user's attention. Prototype 2 improved on this idea by having the cards rise and fall to display instead of dispense them. The servo motor was strong enough to lift 1-25 cards at the same rate, and because there were fewer points of possible error, it proved to be a more successful design. On top of this, if prototype 2 ever broke, you could always pull the cards out manually, which you couldn't do with the other. To answer the question of how we make this detect motion/your hand to present when your hand is close enough, we opted for laser distance sensors.
The next question was how do we make the device grab attention and be portable? As evidenced in our prototype of the exterior, so we could get a good gauge on its form factor, we had to make it large enough to fit 10 cards head-on and grab attention. At the same time, it had to be easily portable. We decided a 2'x2'x8" box was the solution. To make it grab attention, we decided to add a waving Scotty on top.
The final question was how to gamify this. Ryan really wanted to make this a fun experience to draw people to the IDeATe space. We wanted to make a candy dispenser with a reaction time where you could push the card into the slot under Scotty in sync with a pulsing light, and if the times synced up, a candy slide would dispense a piece of candy. Prof. Zach opened our eyes to the issue here. It was with the limited space and time, not to mention potential mechanical failures here. We came to the conclusion that the game and dispenser were just not feasible. We decided to opt for a simpler candy trough at the bottom. While we can't control how much candy people take here, it does help catch the eye of passersby and accomplish a similar effect.
Ultimately, we were surprised how finnicky mechanical mechanisms could be, despite being warned many times, as well as how easy it is to become ambitious and come up with so many features while you should really focus on your essential components before anything else.
After our last prototype, we had already gone into our final build with pared-back features: no more gamification, LED strips lining each pocket, or sensors to read if someone had picked up a card from a particular pocket, let alone what number of cards those were. But it was during the final build that we found ourselves paring back even more, omitting LEDs from the project entirely and, most notably, limiting the number of laser distance sensors to 3 instead of 10, one for each pocket. Our focus shifted towards creating a final, standing product rather than accommodating every feature that we had initially planned. Due to the sheer size of our prototype, there were certain aspects that we did not necessarily have a way of testing beforehand, such as how the build would hold up at the scale we had planned with heavier acrylic pieces instead of lightweight cardboard, or how a system would work with 10 instead of 3 sensors. We had tried our best to account for this in some ways, opting to make the candy trough base out of 6mm thick acrylic instead of the standard 3 mm thickness and opting out of attempting a friction fit for our finger joints to ensure the acrylic wouldn't crack. However, there were still plenty of variables we hadn't accounted for that prompted us to make new decisions on the fly, often trying to find a practical 'next-best' solution when the ideal option wasn't available, as detailed below.
We had to stay really organized to ensure that our assembly process went as smoothly as possible (even if it didn't). Above are the ten servo motors laid out in correspondence to the laser distance sensor they were affected by, of which there were three. From doing this alone, it was easy to gauge that, based on our timeline, it was more practical to limit the number of sensors to reduce the overall hardware and pivot to relying on software to produce similar results of the cards lifting like a 'wave' based on one's hand position, especially considering the mess of wires that was being created in trying to limit the number of microcontrollers for this project to two. We switched to an Arduino Mega so that we would have enough digital input/output pins to work with.
The housing of the display was done in SolidWorks. The pockets had to be made in a way so that there was just enough of a gap to allow a stack of cards to sit in it comfortably while also being small enough to ensure a smooth lift via the servo in the back. This took some trial and error with small tests to see how to join laser-cut pieces at angles had to be modelled and joined so that there was no possibility for a small seam through which small cards could slip out. The overall housing was mainly adjusted around the build of these 10 pockets, but also based on the aesthetic requests on the client's end.
While we had anticipated challenges for the actual assembly, there were definitely some unexpected hiccups. When attempting to remove the pieces that didn't immediately fall out of the front panel after being laser-cut ( namely, the cavities that would be completed by the pockets), our first cut of the front panel cracked in multiple places. Considering that the panel is 23 in. x 21.5 in., being cut out of a 2ft by 2ft panel, this was quite a hurdle, as this was the last available piece of frosted acrylic. For our recut, we took the monitor's advice and first removed all of the paper backing on one of the sides. The adhesive backing would've melted under the hot laser, pulling on the cutouts as we were trying to break them out and causing the cracks, hence needed to be rid of on order to cleanly pop them out. This proved to be very successful, and we ended up keeping the backing on the other side to mimic the translucency of the frosted acrylic as a spontaneous decision.
The pockets were among the first cut pieces to be fully assembled, helpful as the gluing process for these smaller pieces would prove informative when tackling the larger housing. It was a tedious, repetitive process, but surprisingly, it helped to have a part of the broken front panel to stabilize the pocket panels in the right position before gluing them down. Multiple adhesive techniques were experimented with before we landed on B-7000 since we were unable to find acrylic cement, the most ideal option. Both hot glue and standard super glue failed to hold these relatively bulky pieces in place, but once we used B-7000, the process started to go a lot more smoothly.
When putting it together with the electrical components, we were starting to get worried about the overall weight of these components and their ability to be held in the housing, especially considering that we had planned for a removable back in order to make the wiring accessible to Ryan once we handed the display off. We were extremely careful to glue everything down securely in place, adding an extra layer of hot glue around the edges, as well as constantly testing and retesting the servos and sensors as wires were being moved around during assembly, since we did not have enough time to solder all the components. We ultimately ended up hot-gluing the breadboard to make the wiring more permanent, which mitigated this issue.
During the final hours of assembly, we went back to CAD software to attempt different versions of reinforcements: runners that went across the pockets and stuck to the sides, triangles that ran across the different columns. These pieces are cut and still available in case any further reinforcement is necessary. Our display ended up standing quite securely without these extra reinforcements, and so we decided against adding these last-minute reinforcements so as not to interrupt the wiring. With the knowledge we have now about the strength of acrylic based on thickness and where cuts are made, we would definitely go back and redesign the pockets in a way where they could gain support from the side panels to ensure long-term stability.
We ultimately did not end up sticking to our original schedule as a result of these variables, despite making several cuts to our original plan, but we still ended up with a fully functioning build that we were quite happy with.
To make our product more eyecatching and intriguing to passersby, we decided to incorporate a Scotty dog at the top of the structure, made from layers of laser cut acrylic. This gave the display more personality and made it feel more playful and approachable. We also added movement by using a servo motor to make Scotty’s arm wave and OLED displays to animate its blinking eyes, helping attract attention even from a distance.
Initially, we explored making the eyes follow people as they walked by using sensors. However, we ultimately decided against this feature, as it would need additional time without significantly improving the overall experience. Instead, we focused on simple animations that could effectively catch people's attention while keeping the design manageable within our timeline.
Laser-cut acrylic Scotty pieces before assembly.
Two OLED displays were taped to the back of the Scotty figure to create blinking eyes, while a servo motor was attached behind the arm to enable a waving motion. A slot was also cut into the display to allow the Arduino wiring to pass through.
Creating the laser-cut DXF file for Scotty in SolidWorks.
4. Conclusions and lessons learned
On the day of final crit, comments largely fell into three categories: additional interactive features that could be accommodated into the current product, tweaks in software that would improve the overall experience of the display, and more fundamental structural changes that would've made the process significantly smoother for us - valuable more so for future projects. In terms of the former categories, many reviewers mentioned "adding a barking sound", one reviewer even mentioned "[adding] seasonal features to [the] dog". These ideas confirmed a thought we had throughout working on this project, which was that this could possibly be a product that can be tangibly built upon as time goes on, feeding into that collaborative interaction Ryan wanted to facilitate in the first place. These suggestions felt less like shortcomings and more like new opportunities.
When it came to actual critiques, though, feedback could sometimes be contradictory in nature. Written feedback mentioned "being able to turn the Scotty servo on and off" and "having it wave quieter" due to the servo noise being possibly disruptive in a shared study space, while verbally, some reviewers mentioned enjoying the sound as being "in the spirit of IdeAte". We found the suggestion of integrating another distance sensor that would sense when a student walked by to have Scotty wave only when necessary in order to grab attention to be the best compromise that takes into account everyone's perspective. In other cases, where some mentioned there being "no true need for it to be [made out of] clear" acrylic, others loving the exposed wires, we deferred to our client's word as the final say, who had initially requested some level of transparency in order to quite literally 'display' what IdeAte was all about. Some really excellent tweaks for the delay of movement and the range covered by the distance sensors were suggested. One reviewer mentioned that "The delay is a bit noticeable at the moment. For example, we are testing to see if our movements and gestures produce a reaction or not, where in theory it should be definite". While reviewers enjoyed watching the cards go up once they got really close, for more satisfactory interaction, providing the user with a more 'sensitive' experience, where a hand moving across the sensors triggers the cards to more immediately follow it, would make for a more sophisticated experience. Another mentioned that "As of right now, the experience only begins at 1 foot. If you can hint to user interaction at a greater distance, that would bring in more users". These are subtle changes that, on a smaller-scale project, could have been tested and tweaked until the experience was that much more attuned to the user. Given the timeline, however, we found that scale was the single-most significant factor that made it difficult to refine details like we typically would for a project like this, instead having to quite literally focus on the bigger picture. It is what the critical lessons from this project seemed to revolve around for us.
A crucial takeaway was how structural considerations become a lot less forgiving at this scale. The housing, usually a lower priority consideration for physical computing projects, became a highly critical component for our display, something that would not work if the build couldn't hold itself up. While the tweaks in software mentioned were definitely conceivable for us based on all the skills we have developed over the course of this class, reviewer feedback was most revelatory in relation to the question of long-term stability and the positioning of our components. In our final round of crit where we got to speak to Ryan himself, the reviewers mentioned reinforcement by having a bolt running from the pocket to the back panel, and that the distance between the servo motor and cards may be a bit too big, causing an even more delayed reaction when hands move in front of the distance sensor, as it takes a beat after initially moving for the pushing arm to actually come in contact with cards. These are fundamental structural considerations that would have ideally been implemented from the start of this project, but were very valuable insights that the three of us are sure to consider when working on future projects like this.
Overall, there seems to be somewhat of an inversely proportional relationship between scale and complexity, or rather repeatability and complexity. We started very ambitious, inspired by the enthusiastic nature of our client and wanting to execute every hypothetical feature he suggested. However, with every element we were considering, we were also considering a new point of failure. Two of us have a background in industrial design, and so our team has definitely had some experience with conducting interviews and designing for a specific client's needs, but we have never had an experience where a client had so much clarity regarding what they wanted. Rather than the common predicament of trying to extract possible opportunities, attempting to gauge what the client would want based on a vague interview, we were instead posed with a different challenge: knowing exactly what the client wants, how can we negotiate a solution that is within the scope of this project that simultaneously satisfies the essence of what they were asking for? Aditionally, there was definitely an escalation of stakes when considering that this would be a front-facing product that would be available to interact with for people other than just the single client, even if he was the central figure for which we were building. Success would mean finding a simple system that could be relied on for 10 minors rather than attempting to build a full-fledged carnival game, for which developing a working prototype for just one pocket would take the entire 3-week span of the project. It definitely felt like an advantage that Ryan had prior knowledge of this project, so we did not have to overtly manage expectations. Instead, we found through physical prototypes that showing a client a practical feature that functions generates just as much excitement as a crazy idea that never really breaks out of the concept stage, and that reliability is perhaps more valuable than precarious complexity. Were we to start this process all over again, we would have definitely been more resolute about the scope of this project from the start. We do not regret tackling something of this scale, however, as seeing the reactions from our client and members of the IdeAte community alike made every curveball worth it. Ultimately, we feel quite fortunate that we not only built a functioning final outcome, but were able to gain so many valuable lessons in the process that we wouldn't have had if we had gone with an easier direction.
5. Technical details
Single proximity sensor input -> servo motor card lift output diagram. The sensor reads the physical distance to an object in front of it. It sends that information to the servo motor. The Arduino checks if that threshold is passed. Once it does, it rotates the servo motor 90 degrees.
Larger, portable proximity sensor -> servo output diagram. Cut 10 motors down to 1 motor for simplicity's sake. The sensor reads the physical distance to an object in front of it. It sends that information to the servo motor. The Arduino checks if that threshold is passed. Once it does, it rotates the servo motor 90 degrees. The battery pack input assures this can be portable and moved wherever Ryan wants it to.
Functional Block Diagram of Scotty’s Animated Features. The Arduino Uno sends signals to two OLED displays to control the blinking eye animations and to a servo motor to control the waving motion of Scotty’s arm.
Schematic diagram of the wiring for Scotty’s waving-hand mechanism, using a servo motor, and the two OLED displays used for Scotty’s moving eyes.
/*
Project Title: Proximity Activated Servo with Smooth Motion
Description:
This project uses a VL53L0X distance sensor and a servo motor to move a
mechanism when an object comes close. When an object is within about one foot,
the servo moves 90 degrees to the active position. When the object leaves, the
servo returns to rest. A damped spring calculation makes the motion smooth, and
a short hold time and a wider release distance prevent jitter at the boundary.
Pin Mapping:
Arduino pin | Role | Description
____________________________________________________________
20 | I/O | SDA for VL53L0X distance sensor (I2C)
21 | output | SCL for VL53L0X distance sensor (I2C)
30 | output | Controls servo
31 | output | XSHUT reset for distance sensor (released as input)
5V | power | Supplies power to sensor and servo
GND | ground | Common ground for sensor and servo
Libraries:
- Wire.h: I2C communication
- VL53L0X.h: Distance sensor control
- Servo.h: Servo motor control
- math.h: Absolute value for motion settling
Code Credit:
ChatGPT (OpenAI) was used to assist with writing and refining the Arduino code,
including sensor polling, proximity detection, and smooth servo motion.
Code released to the public domain by the author, 11/16/2026
*/
#include <Wire.h>
#include <VL53L0X.h>
#include <Servo.h>
#include <math.h>
VL53L0X sensor;
Servo myServo;
const byte SERVO_PIN = 30;
const byte XSHUT_PIN = 31;
// These positions are 90 degrees apart.
// Change both if your mechanism needs different endpoints.
const float REST_ANGLE = 0.0f;
const float ACTIVE_ANGLE = 90.0f;
// One foot = 304.8 mm.
const uint16_t ENTER_MM = 305;
// Slightly farther release point prevents jitter at the boundary.
const uint16_t LEAVE_MM = 330;
// Lower = slower and floatier. Try 3.0 to 6.0.
const float RESPONSE = 4.0f;
float angle = REST_ANGLE;
float velocity = 0.0f;
bool objectClose = false;
unsigned long lastMotionTime = 0;
unsigned long lastSensorPoll = 0;
unsigned long lastNearbyTime = 0;
unsigned long lastPrintTime = 0;
void setup() {
Serial.begin(115200);
// Reset sensor without driving XSHUT HIGH at 5 V.
digitalWrite(XSHUT_PIN, LOW);
pinMode(XSHUT_PIN, OUTPUT);
delay(10);
// Release XSHUT; assumes the breakout has an onboard pull-up.
pinMode(XSHUT_PIN, INPUT);
delay(10);
Wire.begin();
sensor.setTimeout(100);
if (!sensor.init()) {
Serial.println(
F("Sensor not found. Check model, power, SDA 20 and SCL 21.")
);
while (true) {
delay(100);
}
}
sensor.setMeasurementTimingBudget(33000);
sensor.startContinuous(50);
// Set the initial command before enabling the servo signal.
myServo.write((int)REST_ANGLE);
myServo.attach(SERVO_PIN);
lastMotionTime = millis();
Serial.println(F("Ready. Distance readings are in millimeters."));
}
void loop() {
unsigned long now = millis();
// Poll for a completed measurement without waiting for each reading.
if (now - lastSensorPoll >= 5) {
lastSensorPoll = now;
uint8_t ready =
sensor.readReg(VL53L0X::RESULT_INTERRUPT_STATUS);
if (sensor.last_status == 0 && (ready & 0x07)) {
uint16_t distance =
sensor.readRangeContinuousMillimeters();
bool timedOut = sensor.timeoutOccurred();
bool readingOK =
!timedOut && sensor.last_status == 0 &&
distance > 0 && distance < 8190;
if (readingOK) {
if (!objectClose && distance <= ENTER_MM) {
objectClose = true;
}
if (objectClose && distance <= LEAVE_MM) {
lastNearbyTime = now;
}
if (now - lastPrintTime >= 200) {
lastPrintTime = now;
Serial.print(F("Distance: "));
Serial.print(distance);
Serial.print(F(" mm | Close: "));
Serial.println(objectClose ? F("YES") : F("NO"));
}
}
}
}
// Return after 250 ms without a nearby reading.
// This also handles brief dropouts without twitching.
if (objectClose && now - lastNearbyTime > 250) {
objectClose = false;
}
// Update motion every 10 ms.
if (now - lastMotionTime >= 10) {
float dt = (now - lastMotionTime) / 1000.0f;
lastMotionTime = now;
// Keep the motion calculation stable after an unexpected delay.
if (dt > 0.05f) {
dt = 0.05f;
}
float target = objectClose ? ACTIVE_ANGLE : REST_ANGLE;
// Damped spring: smoothly accelerates and decelerates.
float acceleration =
RESPONSE * RESPONSE * (target - angle)
- 2.0f * RESPONSE * velocity;
velocity += acceleration * dt;
angle += velocity * dt;
// Keep commands within the intended travel range.
if (angle < REST_ANGLE) {
angle = REST_ANGLE;
velocity = 0;
}
if (angle > ACTIVE_ANGLE) {
angle = ACTIVE_ANGLE;
velocity = 0;
}
if (fabsf(target - angle) < 0.1f &&
fabsf(velocity) < 0.2f) {
angle = target;
velocity = 0;
}
myServo.write((int)(angle + 0.5f));
}
}
/*
Project Title: Waving Scotty with Animated Eyes and Moving Arm
Description:
This Scotty two OLED displays to create animated eyes and a continuous rotation servo to move the Scotty's arm. The eyes randomly look left, right, and center, and blink at different intervals. The servo alternates between clockwise and counterclockwise movement to create a waving motion.
Pin Mapping:
Arduino pin | Role | Description
____________________________________________________________
A4 | I/O | SDA for both OLED displays (I2C)
A5 | output | SCL for both OLED displays (I2C)
9 | output | Controls continuous rotation servo
5V | power | Supplies power to OLED displays
GND | ground | Common ground for displays and servo
A0 | input | Unconnected pin used for random seed
Libraries:
- Wire.h: I2C communication
- U8g2lib.h: OLED display graphics
- Servo.h: Servo motor control
Code Credit:
ChatGPT (OpenAI) was used to assist with writing and refining the Arduino code, including OLED eye animation and timing logic.
Code released to the public domain by the author, 10/12/2023
*/
#include <Wire.h>
#include <U8g2lib.h>
#include <Servo.h>
U8G2_SSD1306_128X64_NONAME_1_HW_I2C leftEye(U8G2_R1, U8X8_PIN_NONE);
U8G2_SSD1306_128X64_NONAME_1_HW_I2C rightEye(U8G2_R1, U8X8_PIN_NONE);
Servo handServo;
const int SERVO_PIN = 9;
const int SERVO_STOP = 90;
const int SERVO_RIGHT = 105;
const int SERVO_LEFT = 75;
const unsigned long WAVE_TIME = 180;
const unsigned long STOP_TIME = 80;
int waveStage = 0;
unsigned long lastWaveChange = 0;
int pupilX = 32;
int eyelid = 0;
unsigned long lastEyeUpdate = 0;
unsigned long nextEyeAction = 0;
bool blinking = false;
int blinkFrame = 0;
const int blinkPositions[] = {0, 40, 80, 128, 80, 40, 0};
void drawEye(U8G2 &oled, int x, int lid) {
oled.firstPage();
do {
oled.setDrawColor(0);
oled.drawBox(0, 0, 64, 128);
oled.setDrawColor(1);
oled.drawDisc(x, 92, 7);
if (lid > 0) {
oled.setDrawColor(0);
oled.drawBox(0, 0, 64, lid);
}
} while (oled.nextPage());
}
void drawBothEyes() {
drawEye(leftEye, pupilX, eyelid);
drawEye(rightEye, pupilX, eyelid);
}
void updateServo(unsigned long now) {
unsigned long duration = (waveStage % 2 == 0) ? WAVE_TIME : STOP_TIME;
if (now - lastWaveChange >= duration) {
lastWaveChange = now;
waveStage = (waveStage + 1) % 4;
switch (waveStage) {
case 0:
handServo.write(SERVO_RIGHT);
break;
case 1:
handServo.write(SERVO_STOP);
break;
case 2:
handServo.write(SERVO_LEFT);
break;
case 3:
handServo.write(SERVO_STOP);
break;
}
}
}
void updateEyes(unsigned long now) {
if (blinking) {
if (now - lastEyeUpdate >= 30) {
lastEyeUpdate = now;
eyelid = blinkPositions[blinkFrame];
drawBothEyes();
blinkFrame++;
if (blinkFrame >= 7) {
blinking = false;
blinkFrame = 0;
eyelid = 0;
nextEyeAction = now + random(120, 400);
}
}
return;
}
if (now >= nextEyeAction) {
int positions[] = {20, 32, 44};
pupilX = positions[random(0, 3)];
eyelid = 0;
drawBothEyes();
if (random(0, 3) == 0) {
blinking = true;
blinkFrame = 0;
lastEyeUpdate = now;
}
nextEyeAction = now + random(120, 300);
}
}
void setup() {
Wire.begin();
leftEye.setI2CAddress(0x3C * 2);
rightEye.setI2CAddress(0x3D * 2);
leftEye.begin();
rightEye.begin();
Wire.setClock(400000);
randomSeed(analogRead(A0));
drawBothEyes();
nextEyeAction = millis() + 200;
handServo.attach(SERVO_PIN);
handServo.write(SERVO_RIGHT);
lastWaveChange = millis();
}
void loop() {
unsigned long now = millis();
updateServo(now);
updateEyes(now);
}