Skip to content

Commit ca71dca

Browse files
M4_Eyes: add fizzgig WAVs, change servo writes to microsec
1 parent 80fef81 commit ca71dca

4 files changed

Lines changed: 6 additions & 6 deletions

File tree

M4_Eyes/eyes/fizzgig/angry.wav

105 KB
Binary file not shown.

M4_Eyes/eyes/fizzgig/bark.wav

52.9 KB
Binary file not shown.

M4_Eyes/eyes/fizzgig/growl.wav

145 KB
Binary file not shown.

M4_Eyes/user_fizzgig.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
// Servo stuff
77
Servo myservo;
8-
#define SERVO_MOUTH_OPEN 0
9-
#define SERVO_MOUTH_CLOSED 180
10-
#define SERVO_PIN 3
8+
#define SERVO_MOUTH_OPEN 750 // Servo pulse microseconds
9+
#define SERVO_MOUTH_CLOSED 1850
10+
#define SERVO_PIN 3
1111

12-
#define BUTTON_PIN 2
12+
#define BUTTON_PIN 2
1313

1414
// WAV player stuff
1515
#define WAV_BUFFER_SIZE 256
@@ -66,7 +66,7 @@ void user_loop(void) {
6666
uint32_t elapsed = millis() - wavEventTime; // Time since audio start
6767
uint16_t frac = elapsed % 500; // 0 to 499 = 0.5 sec
6868
float n = 1.0 - ((float)abs(250 - frac) / 500.0); // Ramp 0.5, 1.0, 0.5 in 0.5 sec
69-
myservo.write((int)((float)SERVO_MOUTH_CLOSED + (float)(SERVO_MOUTH_OPEN - SERVO_MOUTH_CLOSED) * n));
69+
myservo.writeMicroseconds((int)((float)SERVO_MOUTH_CLOSED + (float)(SERVO_MOUTH_OPEN - SERVO_MOUTH_CLOSED) * n));
7070
// BUTTON_PIN button is ignored while sound is playing.
7171
} else if(wavListPtr) {
7272
// Not currently playing WAV. Check for button press on pin BUTTON_PIN.
@@ -79,7 +79,7 @@ void user_loop(void) {
7979
}
8080
pinMode(BUTTON_PIN, INPUT);
8181
if(myservo.attached()) { // If servo still active (from recent WAV playing)
82-
myservo.write(SERVO_MOUTH_CLOSED); // Make sure it's in closed position
82+
myservo.writeMicroseconds(SERVO_MOUTH_CLOSED); // Make sure it's in closed position
8383
// If it's been more than 1 sec since audio stopped,
8484
// deactivate the servo to reduce power, heat & noise.
8585
if((millis() - wavEventTime) > 1000) {

0 commit comments

Comments
 (0)