Disco Pig

Made by Chun Wang

Found in DioT 2019: Augmented Objects

Disco Pig is a plush toy that can sing and dance (have the LED light up) when you press its nose. "Singing" is a part of the original design. I only created the "Dance" section.

0

Intention

I have had this singing plush pig toy for a few years. My friends love playing with it whenever they see it. They always call it "the party pig". I thought it would be a fun idea to incorporate IoT techniques to make it even more "party animal".

0

Goal

1. Make the pig dances along with the music

2. The dance is synchronized with the music

3. Users are able to control the dance moves



0

Process

Step 1:

"Dancing" was the first word that jumps to my mind when I start brainstorming. Therefore, I started with a simple LED circuit. 


Step 2:

Since users need to press the pig face to make it sing, I thought I could use the force sensitive resistor  (FSR) to control my LED and later attach the FSR to the pig. Users will activate singing and dancing at the same time by one simple press.  Therefore, I followed the FSR tutorial and updated my circuit. 


Step 3:

Though I cannot change much about how loud the music will play (since that is a part of the original design), I thought it would be nice at least the users can control the dance moves. This time, I added a potentiometer to my circuit to control the LED brightness. 

0
// Define a pin that we'll place the FSR on
// Remember to add a 10K Ohm pull-down resistor too.
int fsrPin = A0;

// Create a variable to hold the FSR reading
int fsrReading = 0;

// Define a pin that we'll place the pot on
int potPin = A5;

// Create a variable to hold the pot reading
int potReading = 0;

// Define a pin we'll place an LED on
int ledPin = D2;
//int ledBluePin = D4;

// Create a variable to store the LED brightness.
int ledBrightness = 0;
// int ledBrightness = 0;



void setup() {

  // Set up the LED for output
  pinMode(ledPin, OUTPUT);
  
// add this line... 
  //pinMode( buttonPin , INPUT_PULLUP); // sets pin as input
}



void loop() {

  // Use analogRead to read the photo cell reading
  // This gives us a value from 0 to 4095
  fsrReading = analogRead(fsrPin);

  // Map this value into the PWM range (0-255)
  // and store as the led brightness
  ledBrightness = map(fsrReading, 0, 4095, 255, 0);

  // fade the LED to the desired brightness
  analogWrite(ledPin, ledBrightness);

  // wait 1/10th of a second and then loop
  //delay(100);
  
  // First... On
 //digitalWrite(ledPin, HIGH);   
  delay(250);               

  // Now... Off
  digitalWrite(ledPin, LOW);   
  delay(250);              
  // rinse + repeat

// Use analogRead to read the potentiometer reading
  // This gives us a value from 0 to 4095
  potReading = analogRead(potPin);
  
// Map this value into the PWM range (0-255)
  // and store as the led brightness
  ledBrightness = map(potReading, 0, 4095, 0, 255);
  
// fade the LED to the desired brightness
  analogWrite(ledPin, ledBrightness);
  
// wait 1/10th of a second and then loop
  delay(100);
}
Click to Expand
0

Next Steps

1. I can see the potential of making the "Disco Pig" become a "Weather Disco Pig". Extracting weather data from the Internet, the pig will have a blue LED on if the local temperature is below 40˚F, and have a red LED on if the local temperature is above 70˚F.

2. Sometimes, the potentiometer and the FSR conflict with each other. (when one works, the other doesn't.) Therefore, I need to look into code one more time and check if there is anything wrong with it. 

0

Reflection

This is my very first IoT project. I learned a lot through the exploration process, like making the circuit, control my components, etc. Although the disco pig cannot solve world serious problems, it is a fun "enchanted object" that will delight people's everyday life. 

0

Feedback

I asked my friend to test the pig. She loves it becoming a singing and dancing toy, and she suggested it can be better if the LED moves can coordinate with the music. In order to do that, I think I need to work on my code in the looping section. Instead of having the LED always delay for 350 mS, I can change the delay time according to the melody. 

x
Share this Project

Courses

49713 Designing for the Internet of Things

· 18 members

A hands-on introductory course exploring the Internet of Things and connected product experiences.


About

Disco Pig is a plush toy that can sing and dance (have the LED light up) when you press its nose. "Singing" is a part of the original design. I only created the "Dance" section.

Created

January 31st, 2019