Pages: [1]   Go Down
Author Topic: Imperial March on a fast switching valve  (Read 1740 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 5
Posts: 229
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I thought that there have been dozens or Imperial marches played by floppy drives or step motors so I might as well do something new...

The video >>
http://youtu.be/VSOXKtjtdbs


Here is that valve I used

It's a fast switching valve - namely Festo MHE3-MS1H-3/2G-QS-6.
Its switch on time is 2.3 ms and it switches off in 2.8ms - very very impressive piece of hardware and they are pretty pricey - luckily I got it for next to nothing.

The circuit is very simple - just a ULN2004A as a driver for the valve.

and here's the code (it's a slightly modified version of a sketch created by Carlton Shepherd)

 
Code:

    const int c = 261;
    const int d = 294;
    const int e = 329;
    const int f = 349;
    const int g = 391;
    const int gS = 415;
    const int a = 440;
    const int aS = 455;
    const int b = 466;
    const int cH = 523;
    const int cSH = 554;
    const int dH = 587;
    const int dSH = 622;
    const int eH = 659;
    const int fH = 698;
    const int fSH = 740;
    const int gH = 784;
    const int gSH = 830;
    const int aH = 880;
     
    const int buzzerPin = 12;
 
     
    int counter = 0;
     
    void setup()
    {
      //Setup pin modes
      pinMode(buzzerPin, OUTPUT);
      pinMode(ledPin1, OUTPUT);
      pinMode(ledPin2, OUTPUT);
    }
     
    void loop()
    {
     
      //Play first section
      firstSection();
     
      //Play second section
      secondSection();
     
      //Variant 1
      beep(f, 250); 
      beep(gS, 500); 
      beep(f, 350); 
      beep(a, 125);
      beep(cH, 500);
      beep(a, 375); 
      beep(cH, 125);
      beep(eH, 650);
     
      delay(500);
     
      //Repeat second section
      secondSection();
     
      //Variant 2
      beep(f, 250); 
      beep(gS, 500); 
      beep(f, 375); 
      beep(cH, 125);
      beep(a, 500); 
      beep(f, 375); 
      beep(cH, 125);
      beep(a, 650); 
     
      delay(650);
    }
     
    void beep(int note, int duration)
    {
      //Play tone on the valve
      tone(buzzerPin, note /4, duration);
     
   
     
      //Stop tone on buzzerPin
      noTone(buzzerPin);
     
      delay(50);
     
      //Increment counter
      counter++;
    }
     
    void firstSection()
    {
      beep(a, 500);
      beep(a, 500);   
      beep(a, 500);
      beep(f, 350);
      beep(cH, 150); 
      beep(a, 500);
      beep(f, 350);
      beep(cH, 150);
      beep(a, 650);
     
      delay(500);
     
      beep(eH, 500);
      beep(eH, 500);
      beep(eH, 500); 
      beep(fH, 350);
      beep(cH, 150);
      beep(gS, 500);
      beep(f, 350);
      beep(cH, 150);
      beep(a, 650);
     
      delay(500);
    }
     
    void secondSection()
    {
      beep(aH, 500);
      beep(a, 300);
      beep(a, 150);
      beep(aH, 500);
      beep(gSH, 325);
      beep(gH, 175);
      beep(fSH, 125);
      beep(fH, 125);   
      beep(fSH, 250);
     
      delay(325);
     
      beep(aS, 250);
      beep(dSH, 500);
      beep(dH, 325); 
      beep(cSH, 175); 
      beep(cH, 125); 
      beep(b, 125); 
      beep(cH, 250); 
     
      delay(350);
    }
Logged

North Queensland, Australia
Online Online
Edison Member
*
Karma: 64
Posts: 2102
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Nice job, just went and had a read on those valves. I liked the ones marked as useful for 'fast sorting'.
Logged


0
Offline Offline
Full Member
***
Karma: 5
Posts: 229
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yeah I've seen a video of a pneumatic sorting machine that used computer vision and air nozzles to blew off defective products from the conveyor belt - very very impressive

Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 144
Posts: 5331
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Its switch on time is 2.3 ms and it switches off in 2.8ms - very very impressive piece of hardware and they are pretty pricey - luckily I got it for next to nothing.

That's faster then my hard disk seek time, and I'm using a Velociraptor!  smiley-surprise
Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Norfolk UK
Offline Offline
Edison Member
*
Karma: 66
Posts: 2467
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Nice, how about placing valve high in the air and pumping water through it so it does a liquid pattern in tune to the music.
Logged

There is no such thing as a stupid question but there are a lot of inquisitive idiots.

0
Offline Offline
Full Member
***
Karma: 5
Posts: 229
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

actually I thought about using butane  smiley-mr-green
Logged

Offline Offline
Sr. Member
****
Karma: 9
Posts: 296
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Awesome.
Logged

Pages: [1]   Go Up
Jump to: