Abstract

Do you want to take your dance moves to the next level? The Dance Belt displays a visual light show based on your hip movements and provides you with key analytics on how to improve your dancing. The Dance Belt tracks your hip movements using accelerometers and gyroscopes positioned on the belt, gathering data that is analyzed to give you feedback on how to optimize your dancing. Furthermore, the Dance Belt uses your movements to control a series of RGB LEDs positioned throughout the belt, helping you literally light up the dance floor.

Promo Video

https://youtu.be/sfLMvla7k0U

Technical Overview

The Dance Belt works by tracking your hip movements using an Adafruit BNO055 Gyroscope. The gyroscope is connected to an Arduino that analyzes your hip movements, lighting up RGB LEDs in the direction you move your hips. The code on the Arduino cycles through colors randomly, keeping viewers engaged in the light show as you move your hips. Each RGB LED is wired to a breadboard using four 22-gauge wires (one for red, green, blue, and ground). Each LED line is connected in series to a 10 kOhm resistor, then connected to a digital output from the Arduino.

Additionally, a Wifi Shield is attached to the top of the Arduino, allowing the Dance Belt to connect to the internet. When the Arduino deduces that you are not moving your hips enough in the x-direction (side-to-side), the Arduino connects to a ThingSpeak server that is paired with Twilio to send you an SMS text message to move your hips more.

Problems We Overcame

  1. The LEDs were drawing too much current, causing the Arduino to no longer detect the Wifi Shield, so we added 10 kOhm resistors to each line.
  2. The 10 kOhm resistors made the red LEDs too dim to see in a lit room, but were the only way to have a functioning belt without a second power source.
  3. The Adafruit Gyroscope/Accelerometer was not natively supported by the Arduino so we had to install and learn the Adafruit/Arduino API.
  4. The original code exceeded the Arduino storage capacity so we had to be clever to achieve the same functionality on a single Arduino.
  5. The Sparkfun Protoshield often had failing pins so we attached a simple breadboard to the bottom of the Arduino to run our circuitry, instead of the Protoshield we originally planned to use.

Code

include include include include include include

char ssid[] = "HP-setup-north"; // your network SSID (name) char pass[] = "detkinlabnorth101999"; // your network password (use for WPA, or use as key for WEP) int keyIndex = 0; // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS; int led1g = 13; int led1b = 12; int led1r = 11; int led2g = 10; int led2b = 9; int led2r = 8; int led3b = 7; int led3g = 6; int led3r = 5; int led4b = 4; int led4g = 3; int led4r = 2;

//thingspeak server char server[] = "api.thingspeak.com";

WiFiClient client;

//API key for the Thingspeak ThingHTTP const String apiKey = "JNXBZBPXXT0PZN5K";

//the number the message should be sent to const String sendNumber = "9546683194";

Adafruit_BNO055 bno = Adafruit_BNO055(55);

void setup() { Serial.begin(9600);

pinMode(led1r, OUTPUT); //PWM LED1 output pinMode(led1g, OUTPUT); //PWM LED1 output pinMode(led1b, OUTPUT); //PWM LED1 output pinMode(led2b, OUTPUT); //PWM LED1 output pinMode(led2g, OUTPUT); //PWM LED1 output pinMode(led2r, OUTPUT); //PWM LED1 output pinMode(led3b, OUTPUT); //PWM LED1 output pinMode(led3g, OUTPUT); //PWM LED1 output pinMode(led3r, OUTPUT); //PWM LED1 output pinMode(led4b, OUTPUT); //PWM LED1 output pinMode(led4g, OUTPUT); //PWM LED1 output pinMode(led4r, OUTPUT); //PWM LED1 output

//set up WiFi: if (WiFi.status() == WL_NO_SHIELD) { Serial.println("WiFi shield not present"); // don't continue: while(true); }

// attempt to connect to Wifi network: while (status != WL_CONNECTED) { Serial.print("Attempting to connect to SSID: "); Serial.println(ssid); // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);

// wait 10 seconds for connection:
delay(10000);

} Serial.println("Connected to wifi"); printWifiStatus();

/* Initialise the sensor / if(!bno.begin()) { / There was a problem detecting the BNO055 ... check your connections */ Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!"); while(1); }

delay(1000);

bno.setExtCrystalUse(true);

}

void loop() { digitalWrite(led1g, HIGH); digitalWrite(led2g, HIGH); digitalWrite(led3b, HIGH); digitalWrite(led4g, HIGH);

sensors_event_t event; bno.getEvent(&event); static boolean bad_dancer = false; static boolean msg_sent = false;

static long start_time;

delay(1000);

if(event.orientation.x < 240){ digitalWrite(led1b, LOW); digitalWrite(led1r, HIGH); }

if(event.orientation.x > 280){ digitalWrite(led4g, LOW); digitalWrite(led4r, HIGH); }

if(event.orientation.z > -150){ digitalWrite(led2g, LOW); digitalWrite(led2r, HIGH); }

if(event.orientation.z < -5){ digitalWrite(led3b, LOW); digitalWrite(led3r, HIGH); }

if(event.orientation.x < 300){ //If reading below this threshold, assume intruder detected if(!bad_dancer){ //If no intruder has been detected yet, set the current time as start time for the buzzer start_time = millis(); } bad_dancer = true; } else{ bad_dancer = false; msg_sent = false; }

if(bad_dancer && !msg_sent){ //If intruder is detected and an alert message has not been sent yet, send a message

//send the sms
Serial.println("Sending SMS");

//this function will send the sms
//the first argument is the number to send to, formatted like this +12345678901
//the second argument is the body of the text message, which must be within URLEncode()
sendSMS(sendNumber, URLEncode("Bro, move your hips more."));
msg_sent = true;

}

}

void sendSMS(String number,String message) { // Make a TCP connection to remote host if (client.connect(server, 80)) {

//should look like this...
//api.thingspeak.com/apps/thinghttp/send_request?api_key={api key}&number={send to number}&message={text body}


client.print("GET /apps/thinghttp/send_request?api_key=");
client.print(apiKey);
client.print("&number=");
client.print(number);
client.print("&message=");
client.print(message);
client.println(" HTTP/1.1");
client.print("Host: ");
client.println(server);
client.println("Connection: close");
client.println();

} else { Serial.println(F("Connection failed")); }

// Check for a response from the server, and route it // out the serial port. while (client.connected()) { if ( client.available() ) { char c = client.read(); Serial.print(c); }
} Serial.println(); client.stop();

}

String URLEncode(const char* msg) { const char *hex = "0123456789abcdef"; String encodedMsg = "";

while (*msg!='\0'){ if( ('a' <= *msg && *msg <= 'z') || ('A' <= *msg && *msg <= 'Z') || ('0' <= *msg && *msg <= '9') ) { encodedMsg += *msg; } else { encodedMsg += '%'; encodedMsg += hex[*msg >> 4]; encodedMsg += hex[*msg & 15]; } msg++; } return encodedMsg; }

void printWifiStatus() { // print the SSID of the network you're attached to: Serial.print("SSID: "); Serial.println(WiFi.SSID());

// print your WiFi shield's IP address: IPAddress ip = WiFi.localIP(); Serial.print("IP Address: "); Serial.println(ip);

// print the received signal strength: long rssi = WiFi.RSSI(); Serial.print("signal strength (RSSI):"); Serial.print(rssi); Serial.println(" dBm"); }

Share this project:

Updates