Рубрики

create

How to create a spooky kitty

In this tutorial, you will learn how to create a Halloween-inspired illustration featuring a cute kitten. You will mostly use ovals and other basic shapes. It’s bit longer than usual but easy to follow, and will lead to an adorable final result. Let’s get started!


Interactive Spooky Halloween Cat

Check out this distance sensing Halloween prop designed to spook the willies out of trick-or-treaters.

  • Distance
  • LED
  • Projects
  • Ultrasonic

As we approach the end of October, the spooky Halloween energy is starting to find its way into my world. I’m not much of a Halloween-er myself, but I have always felt that Halloween is an excellent excuse to show off your killer maker skills, creativity and maybe even scare some folks. This week I made a little interactive Halloween decoration that activates when someone walks by.

My Interactive Spooky Halloween Cat consists of a plastic skeleton cat I found at Michaels and an enclosure that I laser cut from black acrylic. Inside the enclosure is a SparkFun BlackBoard as the brains of the project, an Ultrasonic Sensor for distance sensing, a Qwiic MP3 Trigger Board to add some hissing sound effects, a small hamburger speaker for the sound, a small servo motor to create motion in the cat’s jaw, 16 WS2812 LEDs to create the red light and a small breadboard to make the circuit building quick and easy. A full list of parts used in this project can be found here.

Let’s take a look at how this project interacts with the world around it. When a user enters within 100 cm of the ultrasonic sensor, the skeleton and eye sockets light up, it makes a loud, angry hissing sound, and the jaw begins moving up and down.

In order to accomplish this interaction (in addition to the circuitry described further down), the servo motor is connected to a clear strand of fishing line tied to the bottom of the cat’s jaw bone, so when the servo pulls back, the jaw opens up. I also added some white elastic tied to the top and bottom part of the jaw, kind of like a rubber band on braces, ensuring the jaw closes when the servo pushes back forward. I cut small sound holes in the enclosure above where the speaker is to get the best out of the sound.

I also made some modifications to the WS2812 LEDs. First, I cut two individual LEDs from the strip and soldered them together with hook-up wire at a distance of about one half-inch. Then, I connected these via hook-up wire to the remaining 14 LEDs on the rest of the strip. I unscrewed the cat’s skull to remove it from the body and open it up, then carefully drilled holes in the eye sockets, behind which I glued my two individual LEDs. Then I put the head back together and onto on the rest of the skeleton. Finally, I carefully hot glued the remainder of the LEDs down the inside of the cat’s spine.

Below is a photograph of the circuit I used in this project. Because some of the parts I used are not available for frtizing diagrams, and because it is hard to see all the connections, I created the table below the image to outline each connection used in this project.

interactive cat circuit

PART / PIN CONNECTION
WS2812 Strip VCC 5V on SparkFun BlackBoard
WS2812 GND GND on SparkFun Black Board
WS2812 DIN Pin 6 on SparkFun BlackBoard
Small Servo VCC 5V on the SparkFun BlackBoard
Small Servo GND GND on SparkFun BlackBoard
Small Servo Data Pin Pin 9 on SparkFun BlackBoard
UltraSonic Sensor GND GND on SparkFun BlackBoard
UltraSonic Sensor VCC 5V on the SparkFun BlackBoard
UltraSonic Sensor Echo Pin Pin 12 on SparkFun BlackBoard
UltraSonic Sensor Trig Pin Pin 13 on SparkFun BlackBoard
Qwiic MP3 Trigger Connect to Qwiic connector on SpakrFun BlackBoard via Qwiic Cable
Hamburger Speaker Jack Audio Jack on Qwiic MP3 trigger

My program for this project can be found below. You will notice there are two programs included. The first is the program specific for this project’s interaction. The second is written for interfacing with the MP3 Trigger Shield and should be pasted into a second tab in your Arduino IDE. The MP3 Trigger code has all been picked up from Nate’s example code for this board, which allowed me to add sound incredibly easily!

/*Interactive Halloween Cat Sketch by Melissa Felderman for SparkFun Electrnoics October 2018 MP3 trigger control taken from example code by Nathan Seidle: https://cdn.sparkfun.com/assets/d/d/e/a/1/Qwiic_MP3_Trigger_Examples.zip */ #include #include #include byte mp3Address = 0x37; //Unshifted 7-bit default address for Qwiic MP3 #define PIN 6 #define numPix 16 #define trigPin 13 #define echoPin 12 bool state = true; Servo myservo; Adafruit_NeoPixel strip = Adafruit_NeoPixel(numPix, PIN, NEO_GRB + NEO_KHZ800); void setup() < Serial.begin(9600); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); Wire.begin(); strip.begin(); myservo.attach(9); myservo.write(180); mp3ChangeVolume(31); //Volume can be 0 (off) to 31 (max) >void loop() < long duration, distance; digitalWrite(trigPin, LOW); // Added this line delayMicroseconds(2); // Added this line digitalWrite(trigPin, HIGH); // delayMicroseconds(1000); - Removed this line delayMicroseconds(10); // Added this line digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); distance = (duration / 2) / 29.1; if (distance < 100) < // This is where the LED On/Off happens mp3PlayTrack(1); for (int i = 0; i < numPix; i++) < strip.setPixelColor(i, 255, 0, 0); >strip.show(); for (int i = 0; i < 8; i++)< myservo.write(90); delay(1000); myservo.write(180); delay(1000); >> else < for (int i = 0; i < numPix; i++) < strip.setPixelColor(i, 0, 0, 0); >strip.show(); myservo.write(180); > if (distance >= 100 || distance else < Serial.print(distance); Serial.println(" cm"); >delay(500); > 

MP3 Trigger Code by Nate:

//These are the commands we can send #define COMMAND_STOP 0x00 #define COMMAND_PLAY_TRACK 0x01 //Play a given track number like on a CD: regardless of file names plays 2nd file in dir. #define COMMAND_PLAY_FILENUMBER 0x02 //Play a file # from the root directory: 3 will play F003xxx.mp3 #define COMMAND_PAUSE 0x03 //Will pause if playing, or starting playing if paused #define COMMAND_PLAY_NEXT 0x04 #define COMMAND_PLAY_PREVIOUS 0x05 #define COMMAND_SET_EQ 0x06 #define COMMAND_SET_VOLUME 0x07 #define COMMAND_GET_SONG_COUNT 0x08 //Note: This causes song to stop playing #define COMMAND_GET_SONG_NAME 0x09 //Fill global array with 8 characters of the song name #define COMMAND_GET_PLAY_STATUS 0x0A #define COMMAND_GET_CARD_STATUS 0x0B #define COMMAND_GET_VERSION 0x0C #define COMMAND_SET_ADDRESS 0xC7 //Checks the status of the player to see if MP3 is playing //Returns true if song is playing boolean mp3IsPlaying() < mp3Command(COMMAND_GET_PLAY_STATUS); delay(20); //Give the QMP3 time to get the status byte from MP3 IC before we ask for it //01: play, 02: stop, 03: pause byte playStatus = mp3GetResponse(); if(playStatus == 0x01) return(true); return(false); >//Plays a given track number //Think of this like a CD. The user can arrange the order of MP3s //however. playTrack(4) will play whatever is in the 4th file. void mp3PlayTrack(byte trackNumber) < mp3Command(COMMAND_PLAY_TRACK, trackNumber); //Play track >//Plays a file that has been named specifically. //For example: passing in 6 will play F006xxx.mp3 void mp3PlayFile(byte fileNumber) < mp3Command(COMMAND_PLAY_FILENUMBER, fileNumber); //Play file number >//Stop playing the current track void mp3Stop() < mp3Command(COMMAND_STOP); >//Change the equalizer to one of 6 types void mp3ChangeEQ(byte eqType) < //0-normal, 1-pop, 2-rock, 3-jazz, 4-classical, 5-bass mp3Command(COMMAND_SET_EQ, eqType); //Change equalizer to bass >//Get the current status of the Qwiic MP3 byte mp3Status() < return(mp3GetResponse()); >//Checks to see if MP3 player has a valid SD card boolean mp3HasCard() < mp3Command(COMMAND_GET_CARD_STATUS); delay(20); //Give the QMP3 time to get the status byte from MP3 IC before we ask for it return(mp3GetResponse()); >//Get the 8 characters of the song currently playing String mp3SongName() < String thisSongName = ""; mp3Command(COMMAND_GET_SONG_NAME); delay(50); //Give the QMP3 time to get the name from MP3 IC before we ask for it Wire.requestFrom(mp3Address, 8); //Song names are max 8 chars while(Wire.available()) < thisSongName += (char)Wire.read(); >return(thisSongName); > //Get the number of songs on the SD card (in root and subfolders) //Limited to 255 byte mp3SongCount() < mp3Command(COMMAND_GET_SONG_COUNT); //Get current song count delay(50); //Give the QMP3 time to get the count from MP3 IC before we ask for it return(mp3GetResponse()); >//Change volume to zero (off) to 31 (max) void mp3ChangeVolume(byte volumeLevel) < mp3Command(COMMAND_SET_VOLUME, volumeLevel); //Change volume >//Play the next track //Think of this like a CD. The audio files can be in any order. The user //sets the file order. This plays the next one. void mp3PlayNext() < mp3Command(COMMAND_PLAY_NEXT); >//Play the previous track //Think of this like a CD. The audio files can be in any order. The user //sets the file order. This plays the previous one. void mp3PlayPrevious() < mp3Command(COMMAND_PLAY_PREVIOUS); >//Checks to see if Qwiic MP3 is responding over I2C boolean mp3IsPresent() < Wire.beginTransmission(mp3Address); if (Wire.endTransmission() != 0) return(false); //Sensor did not ACK return(true); >//Pause a currently playing song, or begin playing if current track is paused boolean mp3Pause() < mp3Command(COMMAND_PAUSE); >//Change the I2C address //If you forget what address you've set the QMP3 to then close the //ADR jumper. This will force the I2C address to 0x36 boolean mp3ChangeAddress(byte address) < mp3Command(COMMAND_SET_ADDRESS, address); mp3Address = address; //Change the global variable to match the new address >//Send command to Qwiic MP3 with options boolean mp3Command(byte command, byte option) < Wire.beginTransmission(mp3Address); Wire.write(command); Wire.write(option); if (Wire.endTransmission() != 0) return(false); //Sensor did not ACK return(true); >//Send just a command to Qwiic MP3 boolean mp3Command(byte command) < Wire.beginTransmission(mp3Address); Wire.write(command); if (Wire.endTransmission() != 0) return(false); //Sensor did not ACK return(true); >//Ask for a byte from Qwiic MP3 //The response depends on what the last command was //It is often the system status but can be song count or volume level byte mp3GetResponse() < Wire.requestFrom(mp3Address, 1); if (Wire.available()) return (Wire.read()); Serial.println("Error: Sensor did not respond"); return(0); >//Returns the firmware version as a float float mp3GetVersion() < mp3Command(COMMAND_GET_VERSION); Wire.requestFrom(mp3Address, 2); //2 bytes for Version if (Wire.available() == 0) return 0; float versionNumber = Wire.read(); versionNumber += (float)Wire.read() / 10.0; return (versionNumber); >

I hope you enjoyed reading about this project and that it inspired you to get spooky with your projects this Halloween. Let us know your thoughts in the comments below!





Creating the Head

Step 1

Hit the Ellipse Tool (L) and create an ellipse. Remove the stroke color if you have one, and set the fill color to R=216 G=217 B=218. Take the Direct Selection Tool (A) and select the left and right anchor points, then move them down.

creating the head

Step 2

Now let’s create the ears. We need to draw a triangle (using the same fill color) and we will create it from the Polygon Tool. Take the Polygon Tool and click on your artboard. In the new dialogue window, type 3 Sides with any Radius. Then click OK.

Keep it selected and go to Effect > Warp > Bulge. In the new window, Warp Options will pop up. Be sure to set the Style to Bulge, Bend 60%, Distortion Horizontal 0%, Vertical 0%. Make one more copy of the ear in front (Control-C, Control-F), then make it smaller and set the fill color to R=243 G=117 B=121. We just created one ear of the kitten.

creating the ears

Step 3

Rotate the ear a little bit and place it on the head. Keep the whole ear selected and right-click your mouse. In the pop-up window, select Transform > Reflect. Select Vertical axis of reflection and press Copy.

Move the second ear and place it on the right-hand side. To make the ears right in the middle of the head, you can select both ears, right-click the mouse and select Group. Press the Shift key and hold, and then select the head and the ears together. Go to the Align panel (Window > Align) and press Horizontal Align Center.

placing the ears

Step 4

Now on to the eyes. Choose a green fill color (R=141 G=139 B=0) and using the Ellipse Tool (L) draw an oval. Draw another oval over it and make the fill color darker (R=96 G=91 B=3). Draw a small white circle as a highlight.

Rotate the eye a little to the left. Then create another eye: right-click the mouse and hit Transform > Reflect, Vertical, Copy. Move the new eye on the right-hand side.

creating and putting the eyes

Step 5

Draw a pink oval with the fill color R=243 G=117 B=121. Keeping it selected, hit the Convert Anchor Point Tool (Shift-C) and press on the lowest anchor point to make this sharp. We just created the nose. Place the nose between the eyes, slightly lower.

creating and placing the nose

Step 6

Using the color from the head, we will draw the fur. Adjust the Pencil options: double-click on the Pencil Tool (N) and set the Tolerances Fidelity to 4 px and Smoothness to 40%. Check Fill New Pencil Strokes and then press OK. Try to draw something like in the image below. To close the path, you need to hold the Alt button as you finish the path. Draw three different pieces of fur: on the top of the head, and on the left and right cheek. The head is done!

drawing the fur

Creating the Body

Step 1

Using the Ellipse Tool (L) draw an oval (fill color R=216 G=217 B=218). Take the Direct Selection Tool (A) and, moving the handles, create a shape like in the image below.

creating the body

Step 2

Put the body under the head (Control-X, Control-B).

placing the body

Step 3

Now, we will create a division between the head and the body. Just select the head, make a copy behind (Control-C, Control-B) and move it down a little bit. Make the fill color darker (R=201 G=202 B=204). Then select the body, and make a copy in front (Control-C, Control-F). While holding the Shift key, select the darker copy of the head, and on the Pathfinder panel press the Intersect button.

optically dividing the head and the body

Step 4

This next shape is designed to show the hind paw of the kitten. Draw an oval using the Ellipse Tool (L) with a fill of R=201 G=202 B=204. To make the top and bottom anchor points sharp, take the Convert Anchor Point Tool (Shift-C) and press on these anchor points. Then go to Effect > Warp > Arc. In the new dialogue window, enter the following: Style Arc Vertical, Bend 50%, Distortion Horizontal 0%, Vertical 0%. Press OK. Then expand this shape (Object > Expand Appearance).

creating the shape to show the hind paw

Put the shape where the hind paw has to be. Also, if you don’t like the result you made in the previous step, move the handles of this shape using the Direct Selection Tool (A) to achieve the result you want.

placing the shape to show the hind paw

Step 5

To draw the front legs, start with an oval. Using the Direct Selection Tool (A), move the handles to create the shape shown below. Make another copy (Control-C, Control-B) and make it darker (R=201 G=202 B=204) and a little wider.

creating the front paw

Step 6

Take the two shapes you made in the previous step and put them into their places. Then take just the darker shape and place it where the second paw has to be. Send this second front paw to the back (Control-X, Control-B).

placing the front paws

Step 7

The last part of this cutie is a tail! Again, draw an oval (the same fill color as the body and head). Send it to the back (Control-X, Control-B) and go to Effect > Warp > Arc. In the new dialogue window, enter the following: Style Arc Horizontal, Bend -30%, Distortion Horizontal -65%, Vertical 0%. Press OK. Then expand this shape (Object > Expand Appearance). This cute kitten is done!

creating and placing the tail

Creating the Witch Hat

Step 1

Hit the Polygon Tool and click on your artboard. In a new dialogue window, type 3 Sides with any Radius. Set the fill color at R=0 G=0 B=24. Go to Effect > Warp > Arc. In the new window, select Style Arc Vertical, Bend -30%, Distortion Horizontal 0%, Vertical 0%. Press OK. Then expand this shape (Object > Expand Appearance). Using the Direct Selection Tool (A), move the handles of this shape to achieve the following result.

creating the top of the witch hat

Step 2

Make a new copy in front (Control-C, Control-F). Make the new copy lighter (R=23 G=23 B=44) and make sure that the tops of these two shapes are at the same point.

Set the fill color to R=234 G=96 B=19 and draw a circle on the top. To create a nice round circle, hold the Shift key when creating this shape. Create one lighter (R=243 G=115 B=33) copy of this orange circle to add volume.

creating the top of the witch hat 2

Step 3

Draw an oval for the bottom part of the witch hat. Make a copy of it in front (Control-C, Control-F). Take the Direct Selection Tool (A), select the lowest anchor point on this new copy, and move it up. Keep the last created shape selected, and again make one more copy in the back (Control-C, Control-B). Move it up and set the fill color at R=66 G=66 B=84. The witch hat is done!

creating the bottom of the witch hat

Step 4

Let’s decorate this hat with a bow to make it even more adorable. Draw an oval (did you notice that we are creating this illustration mostly from ovals?). Hit the Eyedropper Tool (I) and take the same orange fill color as the pompom on the top of the hat. Move the top and bottom anchor points to the left using the Direct Selection Tool (A).

Create a second copy of it (Control-C, Control-V) and put them together as shown in the second image. Keep these two shapes selected, right-click your mouse and select Transform > Reflect. Then select Vertical axis of reflection, Angle 90 degrees, and press Copy. Move the two new copies to the right.

creating the bow 1

Step 5

Create an oval (fill color R=243 G=115 B=33) in the middle to make the knot of the bow. The two dark narrow ovals behind the knot will show us the folds of the bow.

creating the bow 2

Step 6

Group the whole bow and place it on the hat.

placing the bow on the witch hat

Colin Wynn
the authorColin Wynn

Leave a Reply