Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Deadmau5 mask


  • Please log in to reply
9 replies to this topic

#1 wabash9000

wabash9000

    Member

  • Members
  • PipPip
  • 10 posts
  • LocationKansas

Posted 24 October 2010 - 08:22 AM

hey guys, just finished my first netduino project. It's my Halloween costume for this year.

Big thanks to members hooked up and to bliptronics for help working out the input from my iphone.

Posted Image

http://www.youtube.com/watch?v=1OWVp4aJjic

/* Code to read the Spectrum Analyzer chip from bliptronics.com
 * http://www.bliptronics.com/item.aspx?ItemID=116
 * 
 * Important: Connect a wire from the 3.3v to the ahref on the shield to work with netduino.
 * 
 * * Based on code from bliptronics.com and arduino community assistance.
 * Port by: Joseph Francis
 */

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;

namespace BlipSpectrumAnalyzer
{
    public class Program
    {
        static OutputPort spStrobe = new OutputPort(Pins.GPIO_PIN_D12, false);
        static OutputPort spReset = new OutputPort(Pins.GPIO_PIN_D13, false);
        static OutputPort redled = new OutputPort(Pins.GPIO_PIN_D1, false);
        static OutputPort greenled = new OutputPort(Pins.GPIO_PIN_D2,false);
        static OutputPort blueled = new OutputPort(Pins.GPIO_PIN_D3, false);
        static TimeSpan ts = new TimeSpan();
        static int beatCount;
        static int color;
        static AnalogInput spReadL = new AnalogInput(Pins.GPIO_PIN_A0);
        static AnalogInput spReadR = new AnalogInput(Pins.GPIO_PIN_A1);
        static bool music = false;
        const int MUSIC_MIN = 190;
        static Thread t = new Thread(new ThreadStart(light));

        static public void setupSpecrum()
        {
            spReset.Write(true);
            Thread.Sleep(1);
            spReset.Write(false);
            Thread.Sleep(1);
            beatCount = 0;
            color = 0;
        }


        static public void readSpecrum()
        {
            byte Band;
            for (Band = 0; Band < 7; Band++)
            {
                //--- Trigger strobe to make multiplexer jump
                spStrobe.Write(true);
                spStrobe.Write(false);
                if (Band == 0)
                {
                    int cVal = spReadL.Read();
                    cVal += spReadR.Read();
                    cVal /= 2;
                    Debug.Print(cVal.ToString());
                    if (cVal < MUSIC_MIN && ((Utility.GetMachineTime()-ts) > new TimeSpan(0, 0, 5) || ts.Equals(new TimeSpan())))
                    {
                        t = new Thread(new ThreadStart(light));
                        t.Start();
                        Thread.Sleep(454);

                    }
                    else if (cVal > 800)
                    {
                        if (!t.IsAlive)
                        {
                            t = new Thread(new ThreadStart(light));
                            t.Start();
                            ts = Utility.GetMachineTime();
                        }
                    }
                    else
                    {
                        Debug.Print(Utility.GetMachineTime().ToString());
                        if ((ts - Utility.GetMachineTime()) > new TimeSpan(0, 0, 5))
                        {
                            beatCount = 0;
                        }
                    }
                }
            }           
        }
        public static void light()
        {
            switch (color)
            {
                case 0:
                    Debug.Print("RED TICK " + beatCount);
                    redled.Write(true);
                    beatCount++;
                    
                    Thread.Sleep(125);
                    redled.Write(false);
                    break;
                case 1:
                    Debug.Print("GREEN TICK " + beatCount);
                    greenled.Write(true);
                    beatCount++;
                    Thread.Sleep(125);
                    greenled.Write(false);
                    break;
                case 2:
                    Debug.Print("BlUE TICK " + beatCount);
                    blueled.Write(true);
                    beatCount++;
                    Thread.Sleep(125);
                    blueled.Write(false);
                    break;
            };
            if (beatCount == 4)
            {
                beatCount = 0;
                color++;
                if (color == 3)
                {
                    color = 0;
                }
            }
        }
        public static void Main()
        {
            setupSpecrum();
            while (true)
            {
                readSpecrum();
            }
        }

    }
}

  • NeonMika / Markus VV. likes this

#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 24 October 2010 - 08:34 AM

That's pretty cool! Are you controlling the colors from the phone? Chris

#3 bill.french

bill.french

    Advanced Member

  • Members
  • PipPipPip
  • 260 posts
  • LocationPrinceton, NJ

Posted 24 October 2010 - 01:01 PM

I am guessing he's using the phone simply as a source of music, so yes, in a sense, he is controlling the colors from the phone, although fairly indirectly.

#4 wabash9000

wabash9000

    Member

  • Members
  • PipPip
  • 10 posts
  • LocationKansas

Posted 24 October 2010 - 03:00 PM

the phone is used for the music. the program listens to the music and filters out only the bass and then when the bass hits it flashes the lights. every 4 times it flashes the lights change colors. if no music is detected for 5 seconds it flashes at a rate of 132 bpm.

#5 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 24 October 2010 - 05:40 PM

the phone is used for the music.
the program listens to the music and filters out only the bass and then when the bass hits it flashes the lights. every 4 times it flashes the lights change colors. if no music is detected for 5 seconds it flashes at a rate of 132 bpm.


Now that is awesome. I'm just realizing what deadmau5 is...very creative!

Chris

#6 Omar (OZ)

Omar (OZ)

    Advanced Member

  • Members
  • PipPipPip
  • 564 posts

Posted 24 October 2010 - 08:32 PM

WOW I love it XD its soo cool. you could place speakers on the ears so people can hear the music? that would be sick

#7 wabash9000

wabash9000

    Member

  • Members
  • PipPip
  • 10 posts
  • LocationKansas

Posted 25 October 2010 - 03:11 AM

If you turn up the video I do have speakers in it, I wanted to put them in the ears but I didn't want to make them that thick. They are in the sides of the head. They get plenty load in person but so some reason my iPhone didn't capture the audio very well.

#8 Omar (OZ)

Omar (OZ)

    Advanced Member

  • Members
  • PipPipPip
  • 564 posts

Posted 25 October 2010 - 08:32 PM

If you turn up the video I do have speakers in it, I wanted to put them in the ears but I didn't want to make them that thick. They are in the sides of the head. They get plenty load in person but so some reason my iPhone didn't capture the audio very well.

Oh sorry thats my fault, my sound was off. Its loud, you should film it on Halloween so we can see people's reactions.

#9 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 28 October 2010 - 04:27 AM

It looks like your Deadmau5 Halloween mask has quite a few fans. MAKE just featured it on their blog...and a bunch of people are tweeting about it.

Again, great job on the costume!

Chris

#10 bill.french

bill.french

    Advanced Member

  • Members
  • PipPipPip
  • 260 posts
  • LocationPrinceton, NJ

Posted 03 November 2010 - 09:10 PM

So.... How did the costume work out??




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.