快穿之娇软迷人h

快穿之娇软迷人h

Tuesday, June 7, 2011

Rain Barrels on Crack

I built a rain barrel setup a few years ago for my garden / yard, complete with a rather powerful electric pump to provide some needed water pressure for a spray nozzle, sprinkler, extra-long garden hose, or what have you.  I wasn't really trying to be green when I put this sucker together, I just wanted to save some damn money on my water bill.  Little did I know, the electric pump I used with the barrels would cause a serious uproar with my neighbors - I got a lot of: "Well that's not very green...using electricity to pump your rainwater!" and of course the: "Are you really saving any money on water when you're paying for the electricity to use that pump?!" and the ever-popular: "If you spray my kid in the face one more time with your 70 psi f*&%ing rainwater I'm gonna sue!!"  Not gonna lie, that pump was really pissing people off.  So I decided to add a solar / battery power system to the whole setup and make it TOTALLY green.  

Or sort of a fiery-red?


So.  Back up a few years to the process of building the rain barrels themselves.  To start, I poured a small concrete slab for the two 55 gallon food-grade poly barrels I found on Craigslist.  Went with plastic since it obviously doesn't rust, and clear so I could see the water level.  Of course after a month or so of water sitting in 80 degree heat, a nice coat of algae formed on the inside of the barrels, rendering sight a little difficult...but not impossible.  
The barrels are fed by one downspout, which to my surprise provided plenty of water.  Just an hour of moderate intensity rain will fill both barrels.  Heavy rainfall, a matter of minutes.  I fashioned a removable pre-filter to catch leaves and other large debris by epoxy-ing a wire downspout mesh into a 4x2 PVC pipe reducer.  The hole in the top of the rain barrel is just large enough to accept the 2-inch side of the reducer, and the gutter downspout sits right inside the 4-inch part of the reducer. 


Voilà.  I should patent this shit.


Downstream, I used flexible PVC pipe to join the barrels and connect them to the pump via a line strainer.  This single pipe serves as both the fill and the discharge from the second barrel and keeps the water level in each tank the same via hydrostatic equilibrium.  The actual connection from the pipe to the plastic barrels was made through an iron pipe nipple.  This does two things - threading it directly into the barrel makes a tight seal that doesn't require any additional sealing or gaskets, and it allows for detachment of the hoses from the barrels.  You can almost see it here - 


Like how you almost made the A team.


I included a PVC union between the two barrels and another before the pump / line strainer to allow for disassembly and drainage at the end of the season.  Both barrels have a small opening at the top for air venting. The line strainer has NPT pipe threads and a removable canister which houses a stainless steel mesh screen filter.  The pump is a handy dandy little Dayton Utility Pump purchased from Grainger, the specs can be found here.  


I may not look like much, but I'm a pro at pretending to be a ninja.


Essentially everything is connected by an assortment of PVC solvent-welded fittings, PVC unions, and threaded fittings, including the piece of flexible PVC from the discharge side of the pump up to a tee fitting that feeds into two hose bibs - one on each side of the fence.  


The valve is just there for Feng Shui.


Overflow is handled by a 2 inch PVC pipe attached at the top of one of the barrels, also through an iron pipe nipple, as shown here - 


"If you're gonna spew, spew into this."


The PVC pipe feeds into a flexible rubber hose which simply runs around to the front of the barrels and discharges away from the house.


Here's the whole setup - 







So...back to the solar power / battery arrangement.  Essentially, the solar panel will charge a 12 volt battery and an inverter will convert the 12 volt DC battery power into 120 volt AC in order to run the pump.  I found a 15 watt @ 12 volt solar panel on Ebay for around $50, and a permanent-mount 1000 watt inverter for even less.  The pump motor draws 6.5 amps @ 120vAC, so using Watts Law this equates to about 800 watts.  The inverter is capable of delivering a 2000 watt surge, so a little extra current draw required during motor start-up shouldn't be a problem.  Here she is -   
   
Yes, she's a she.  Her name is Susie. 


The battery is a 12-volt commercial type, and is similar in size and shape to a automotive battery, but has 5/16 inch threaded studs as connecting terminals instead of clamp-style posts.  The solar charge controller shown below will keep the solar panel from overcharging the battery. It even has three indicator lights in a stoplight-like configuration - Red: Solar Power Available, Yellow: Charging, and Green: Charged.


"I live my life a quarter watt at a time."


To get the most exposure, I mounted the south-facing 38x12 solar panel on a treated 4x4 post in the backyard, next to the existing eye-sore, my satellite dish.  Unfortunately, the rain barrels are on the north side of the house where there's practically no direct sunlight, so I couldn't put the panel near them.  I made a mounting bracket arrangement out of 1 inch aluminum angle iron that would allow for pitch adjustment of the solar panel throughout the year.  To catch the most sun in the summer months, the panel will be about 25 degrees from horizontal.  In the winter, around 65 degrees. 






To make the run back to the house, I buried 16 gauge outdoor "landscape cable," which I found at the local home improvement store for about $16 per 100 ft length.  Cheap and bury-able. 


'Nuff said.


Since the inverter had to be kept dry (and reasonably cool) I decided to mount it, along with the battery and charge controller, inside the house.  Conveniently, just on the other side of the wall where the rain barrels reside, is the laundry room.  I cut a few pieces of 3/4 inch particle board for a mounting base / shelf for the components and fastened it to the wall in a location where it would be visible but out of harms way - 


Right above the beer fridge in case Susie gets thirsty.


I wired the inverter to the battery with #4 copper battery cable with ring terminals.  Large conductor wire was necessary since at full load the inverter will draw close to 100 amps from the battery.  (1000 watts / 12 volts = 83.3 amps x 20% efficiency loss = 99 amps)  The solar panel supply cable is connected to the charge controller, which is then also connected to the battery.  Here's a closer view - 






The solar panel supply and 120 volt return pass through the wall (just below the shelf) through 1/2 inch EMT conduit and into the switch and outlet mounted outside - 






The solar panel supply cable exits through the bottom of the outlet box and makes its way out to the solar panel in the back yard.  The lower receptacle of the outlet (where the pump is plugged in) is switched by the above weatherproof toggle, while the upper receptacle is "always on."  The painted outlet box to the left is the existing, mains-powered outlet.  


And that's about it!  A complete, self-sustaining pressurized water supply for my entire garden / yard that uses no fossil-fueled electricity or city water resources.  As an added bonus, the inverter (and battery) is large enough to power just about any appliance, electronic, or light in the house (except the A/C or the stove/oven for instance) so when the power goes out, guess who will still be watching re-runs of Sister Sister?  That's right.  This guy.  


Take that, neighbors. 

Thursday, April 14, 2011

The Cooler Radio


So I wanted some sort of portable stereo that was somewhat water resistant to take tubing or camping or tailgating or what have you.  Found a basic Coleman cooler at a garage sale, figured it would do the trick.  You can buy these online, or just make your own...  Here's how I did it.


Actually, this was pretty much conceived out of sheer boredom.


My plan was to use a car stereo and speakers, since they would easily mount in the wall of the cooler using their included hardware.  I figured that since a car stereo would require some sort of 12 volt battery, a "cigarette-lighter" accessory outlet for charging / powering a cell phone or iPod would be pretty useful too.  Also included would be a simple toggle switch to power everything on / off and an analog DC voltmeter salvaged from an old power supply.

These coolers are pretty easy to work with, basically consisting of two pieces of thin plastic separated by expanding foam insulation.  The inner and outer plastic shells can be cut with an ordinary box knife, which is what I used.  A jigsaw would be ideal.

I traced out mounting holes for the car stereo, power switch, accessory outlet, voltmeter, and speakers, then started cutting.  You can see the 1-inch layer of foam insulation between the inside and outside panels -

I'll take six Shlitz's...or whatever's free.

The speakers came with Phillips-head screws, so I simply drove those into the side of the cooler.  The power switch and 12v accessory outlet were surface mount type, which have tabs that snap outward behind the mounting surface -

"I'll charge your iPhone alright...I'll charge it good."

Out of an old HP printer.
Re-purposin' like I give a damn.

The voltmeter had two mounting screws built into the back bezel, but weren't long enough to go through the cooler wall, so I used hot glue to mount.  Easy enough. 

Plutonium chamber = Empty.  Shit.

The car stereo was installed just as it would in a vehicle - the provided metal sleeve's tabs were bent around and behind the face of the cooler front.  The stereo unit then simply slides into the metal sleeve and locks itself into place.

Yep, just like in your '84 Oldsmo-Buick.

Due to space constraints, the battery had to be installed before the stereo could be inserted into the sleeve.  I wanted a battery that would last a while...and figured I might as well use up some of that room inside the cooler...so I used a lawn tractor battery.  From one of these - 

You say overkill, I say fuck you. 

Now that the battery was in, the wiring connections could be made.  Nothing too complicated, just basically joining all the "positives" together, all the "negatives" together, and connecting the speaker leads to the appropriate wires on the radio wiring harness.   Here's a schematic - 

Can I MS Paint, or what?

Starting with the positive connections, I fastened the orange wire from the switch to the positive terminal on the battery with a crimp-style ring terminal.  Then I  soldered the other wire from the switch to the red wire from the outlet, the red and yellow wires from the stereo, and the positive wire from the voltmeter.  A wire from the ring terminal on the negative side of the battery was then soldered to the black wire from the stereo, the black wire from the outlet, and the negative wire from the voltmeter.  Heat shrink tubing was used over the connections...

Heat shrink tubing pre-pool party

Heat shrink tubing post-pool party

Some of the stereo's wiring wasn't used - the "front" speaker wires, the amplifier / power antenna signal, and the illumination wire, so I just bundled these up with a wire tie and tucked them out of the way - 

Big ass lawn tractor battery always tryin' to photo bomb

Here's a view of everything inside the cooler installed and connected, just prior to the stereo being inserted.  You can see the black wiring connector that will plug into the back of the stereo...

Still plenty of room for your diabetic testing supplies! 

Speaking of the stereo, I picked up a top-o-the line Wal-Mart special...complete with USB reader, SD Card support, and an AUX-IN jack for iPod connection -  
Wal-Mart stereos are the Jenny McCarthys of the car audio industry.

Used a few wire ties to clean up some of the wiring - 



Al Green would be proud

Finally, after sliding the stereo unit into its sleeve and plugging in the connector, it was done.  A pic of the radio in operation while charging my cell -  

I actually haven't been tubing or camping in years,
so this will make a nice addition to the back of the garage.

Tuesday, February 15, 2011

The Daft Punk Style Helmets

These helmets were made for the 2011 Omaha Groundhog Prom.  The best explanation I could find...  And, if you're not familiar with Daft Punk, click here.  Here's what we were going for:


Wait a minute, is that a Members Only Jacket?


To go along with our costumes, we wanted some sort of lighted helmet that would have a robot-like appearance similar to the Daft Punk guys, but still be able to see out of them.  I decided on a 90-LED "circuit" board out of 1/32 inch (flexible) plexiglass, powered by an Arduino microcontroller, mounted just behind the visor of the helmet.  I had 5 weeknights to build two of them.  Here's how I did it.


We found a couple of cheap albeit decent looking motorcycle helmets on Ebay for about $30 each. 


Pretty sure these $30 helmets are not D.O.T. approved.

Although the helmets came with both a clear and a smoked visor, the look of the smoked visor was essential in keeping with the "non-human" looking appearance.  In low light with the visor down, it was downright impossible to see in, but relatively easy to see out.  


I wanted to take advantage of as much of the space behind the visor as possible.  I made a quick paper template of the visor's viewable surface area, and drew up grid patterns in a few different configurations before settling on this -  


Why yes, you DO need a drafting scale to make 1/2 inch grid lines. Asshole.
  
This pattern would allow for 90 LEDs spaced on a 1/2 inch by 1/2 inch grid, the top 4 rows being 18 columns wide, the 5th row having 12 wide, and a sixth row with 6 LEDs.  This way, when fitted to the curvature of the visor, the bulk of the lighting was in the front of the viewing area, yet with plenty of lights wrapping around the sides. 


Using the template, I traced and cut out a few pieces of thin plexiglass.  I was surprised to learn that tin snips would cut thin plexiglass, as long as I was taking short snips and taking off less than 3/8 inch or so at a time.  I taped the template and pieces of plexiglass together (including a third sheet as a spare) and began drilling holes, using a piece of 1x6 as backing.  


Psshh...pine.  The Mark Wahlberg of building materials.  Might as well be using dirt. 


To keep things in a straight line, I started by drilling 1/16 inch holes, followed by 1/8 and then the final size - 13/64.  Got a few small cracks, but for hand drilling, it turned out pretty well.    


Cracks?  More like character. 


Next, I set each LED with a dab of hot glue, keeping all the leads in line.  I looked for the brightest LEDs I could find for the price.  These are Kingbright 400mcd diffused reds - 1.85v @ 20mA.  Picked up 200 for 5 1/2 cents each at Mouser.com.  The datasheet is here.


Jefe: Oh yes, you have a plethora.
El Guapo: Jefe, what is a plethora? 


For the first helmet, I glued the LEDs in place after bending the plexiglass to fit the contour of the visor.  I figured if I glued them in first and then bent the plexi, it would put undue stress on the holes/glue, which may cause it to crack or break.  This didn't appear to be necessary.  With the LEDs mounted, the plexi was still quite flexible and I didn't have any problems.  To hold the plexi in its curved shape until I could fit it into the helmet, I simply used a piece of 16awg solid conductor wire, bent around the sides as shown -


Normally, I'm a three-wire kinda guy.


Starting to come together: The first plexiglass board, with the LEDs glued in - 


Awwwwwh Yeeeaaahhh


Next, I bent each LED's lead at a 90 degree angle and soldered them to the next LED in the column.  Thus, each column would light together.  Unfortunately this would only allow for a limited number of lighting effects - a matrix configuration would have been optimal.  More on this later.  Difficult to see, but the picture below shows the columns soldered together.  Still plenty of room to see out!


But you, sir, cannot see in.


On to the fun stuff.  I needed something to control 90 LEDs (really only 18 since they're connected by column).  Since I planned on embedding everything in the helmet, it was going to have to be small.   I've been playing around with the Arduino boards for a while now, and am amazed at their capability.  If you're not familiar, they're easy to use and there's a ton of support available.  Check out http://www.arduino.cc/  At about 2 inches square and $20 from Sparkfun electronics, the Arduino Pro would do nicely:


I did not steal this picture.  I did not steal this picture.  I did not steal this picture.


The Arduino Pro has an available 14 digital input / outputs and 6 analog inputs, of which [the analog inputs] can be software configured to also be used as digital outputs.  Since I have 18 columns of lights to control, I used digital pins 0-13 and analog pins 0-3, leaving analog pins 4 and 5 as inputs, which I will also use.  More on this later. 


The Arduino is capable of sinking or sourcing up to 40mA at each pin.  Each LED, however, uses (up to) 20mA, which means we're going to need transistors to switch the loads.  Nothing special here, I just used some cheap 2N2222's with a 1k ohm base resistor.  Since I didn't have the time nor the space inside the helmet to build a circuit board for all 18 transistors and their respective support components, I decided to mount them in the plexiglass at the tops of each column as shown:


Transistors: the things that let you download porn and listen to mp3's at the same time!
  
Since each LED is rated at 20mA, the total current consumption for each column would be between 80 and 120mA.  (The actual current consumption was later determined to be considerably less, but we'll consider that a different topic..)  Since we're using a 6 volt source to power everything, and the LEDs require 1.85 volts, we'll need a voltage dropping / current limiting resistor at each column.  You can see these mounted at the bottom of each column in the picture above.  Since the LEDs are wired in parallel, the resistor will have to drop 4.15 volts.  Using Ohms law: (6v - 1.85v) / 0.1A = 41.5 ohms,  (the 0.1A is just the average column current) so a 39 ohm resistor would do fine.  Using Watt's law: 4.15 volts x 0.1 amps = 0.415 watts, so I used 1/2 watt resistors.  Here's the schematic for each column - 



Yes, 18x of these.  Ahh, the magical age of...er, number 18.




After connecting and soldering up all the components on the plexiglass, I used an old 20 conductor parallel printer cable and a 2 conductor 18 awg power cord to connect the LED board to the Arduino and battery pack, respectively.  I mounted the LED board inside the helmet about 1/4 inch behind the visor and the Arduino board just below the visor, as shown below - 


The teardrop-lookin thing is not the helmet telling you it's unhappy.  Helmets love Daft Punk.

The data cable sort-of snakes it's way around the side of the helmet and over to one side of the LED board.  This allows for the visor to be opened if needed, with no wires showing.  The dials on the right are just potentiometers - one is connected to Analog Input 5 and is used to select between the different light effects.  The second is used for sensitivity control, connected to a separate circuit board shown below, for the sound-to-light effect.


Cute little guy.


This is an old Velleman Sound-to-light kit, re-purposed to provide more of a sound-to-voltage signal for the Arduino.  It originally had 4 on-board LEDs and an on-board microphone and sensitivity control.  For about $6, it worked extremely well.  I removed the LEDs and soldered a 10k resistor in their place.  I also removed and re-wired the microphone and sensitivity control, as shown above, in order to remotely mount them.  When connected to the 6 volt power source, it provided a nice 0 to 5 volt signal based on the sound level at the microphone, which is exactly the range of the Arduino's analog to digital converter.  This was then connected to the Arduino's analog input 4 through a 1k resistor, and tucked inside the helmet next to the Arduino, as shown here - 


Well...kinda.


Toward the left of the photo you can also see where I mounted the microphone.  


Finally time to program the Arduino.  Given the fact that I only had vertical columns of lights to work with, I couldn't do anything really cool like display scrolling words across the visor, so I was limited to the following sequences.  Had I connected the LEDs in a matrix configuration, I would have a few more options.  Unfortunately, a matrix configuration would require 24 outputs to my available 18, additional components, and considerably more programming.  All of which I didn't have time for.  So here's what I could do with vertical columns - 
  • Left to Right flashing 
  • Left to Right "negative" flashing
  • Middle to Sides flashing
  • Sides to Middle flashing
  • All flashing at a high rate
  • All On steady
  • Random lighting
  • Sound-to-light
The program is shown at the end of the page.  

That's about it!  They're a far cry from the original Daft Punk helmets, but they worked well for our little costume party.  I read somewhere that the company that made the original Daft Punk helmets will make you one (the multi-colored one) for $64,000.00.  I made both of these for about $130.00, including the cost of the helmets.  Here's a few videos showing their operation and pics of us in costume - 


The first video is just a demo of the first 6 sequences - 


Next video shows the random lighting effect - randomly lights between 3 and 9 columns of light each for a random time between 50ms and 1 sec - 


And finally, the sound-to-light part of the program - 



With the visors open:


Number 1 at something, anyway.


On stage:


Security detail.  Long story short: we were drinking and this was our only ticket to getting up on stage.
Long story even shorter:  We were drinking. 


The code.  (Thanks again to JR for all his help here!  If you're familiar with C++, you can probably tell which parts I wrote and which parts he wrote...)


快穿之娇软迷人hint soundpin = 4; // analog sound input on pin 4int selectpin = 5;// analog input on analog pin 5 int pinArray[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};  

int count = 0; // for left to right sequencesint timer = 15; // for left to right sequencesint timer2 = 50; // for middle - out sequenceslong prevMilliseconds = 0; // for random light sequencelong currInterval = 0; // for random light sequence int value = 0;// the value of the potentiometer position void setup(){pinMode(soundpin, INPUT);pinMode(selectpin, INPUT); for (count=0;count<16;count++) {pinMode(pinArray[count], OUTPUT);}}  void sequence1() // left to right sequence{for (count=0;count<16;count++) { digitalWrite(pinArray[count], HIGH); delay(timer); digitalWrite(pinArray[count + 1], HIGH); delay(timer); digitalWrite(pinArray[count + 2], HIGH); delay(timer); digitalWrite(pinArray[count + 3], HIGH); delay(timer); digitalWrite(pinArray[count + 2], LOW); delay(timer); digitalWrite(pinArray[count + 1], LOW); delay(timer); digitalWrite(pinArray[count], LOW); delay(timer*2);}}void sequence2() // left to right reverse lighting sequence{TurnAllPinsOn();for (count=0;count<16;count++) { digitalWrite(pinArray[count], LOW); delay(timer); digitalWrite(pinArray[count + 1], LOW); delay(timer); digitalWrite(pinArray[count + 2], LOW); delay(timer); digitalWrite(pinArray[count + 3], LOW); delay(timer); digitalWrite(pinArray[count + 2], HIGH); delay(timer); digitalWrite(pinArray[count + 1], HIGH); delay(timer); digitalWrite(pinArray[count], HIGH); delay(timer*2);}} void sequence3() //sides to middle sequence{digitalWrite(0, HIGH);digitalWrite(17, HIGH);delay(timer2);digitalWrite(1, HIGH);digitalWrite(16, HIGH);delay(timer2);digitalWrite(2, HIGH);digitalWrite(15, HIGH);delay(timer2);digitalWrite(3, HIGH);digitalWrite(14, HIGH);digitalWrite(0, LOW);digitalWrite(17, LOW);delay(timer2);digitalWrite(4, HIGH);digitalWrite(13, HIGH);digitalWrite(1, LOW);digitalWrite(16, LOW);delay(timer2);digitalWrite(5, HIGH);digitalWrite(12, HIGH);digitalWrite(2, LOW);digitalWrite(15, LOW);delay(timer2);digitalWrite(6, HIGH);digitalWrite(11, HIGH);digitalWrite(3, LOW);digitalWrite(14, LOW);delay(timer2);digitalWrite(7, HIGH);digitalWrite(10, HIGH);digitalWrite(4, LOW);digitalWrite(13, LOW);delay(timer2);digitalWrite(8, HIGH);digitalWrite(9, HIGH);digitalWrite(5, LOW);digitalWrite(12, LOW);delay(timer2);digitalWrite(6, LOW);digitalWrite(11, LOW);delay(timer2);digitalWrite(7, LOW);digitalWrite(10, LOW);delay(timer2);digitalWrite(8, LOW);digitalWrite(9, LOW);}void sequence4() // middle to sides sequence{digitalWrite(8, HIGH);digitalWrite(9, HIGH);delay(timer2);digitalWrite(7, HIGH);digitalWrite(10, HIGH);delay(timer2);digitalWrite(6, HIGH);digitalWrite(11, HIGH);delay(timer2);digitalWrite(5, HIGH);digitalWrite(12, HIGH);digitalWrite(8, LOW);digitalWrite(9, LOW);delay(timer2);digitalWrite(4, HIGH);digitalWrite(13, HIGH);digitalWrite(7, LOW);digitalWrite(10, LOW);delay(timer2);digitalWrite(3, HIGH);digitalWrite(14, HIGH);digitalWrite(6, LOW);digitalWrite(11, LOW);delay(timer2);digitalWrite(2, HIGH);digitalWrite(15, HIGH);digitalWrite(5, LOW);digitalWrite(12, LOW);delay(timer2);digitalWrite(1, HIGH);digitalWrite(16, HIGH);digitalWrite(4, LOW);digitalWrite(13, LOW);delay(timer2);digitalWrite(0, HIGH);digitalWrite(17, HIGH);digitalWrite(3, LOW);digitalWrite(14, LOW);delay(timer2);digitalWrite(2, LOW);digitalWrite(15, LOW);delay(timer2);digitalWrite(1, LOW);digitalWrite(16, LOW);delay(timer2);digitalWrite(0, LOW);digitalWrite(17, LOW);} void sequence5() // high rate flashing{ TurnAllPinsOn(); delay(50); TurnAllPinsOff(); delay(50);}void sequence6() // all lights on{ TurnAllPinsOn();} void sequence7() // random flashing{int minNumberOfLights = 3; int maxNumberOfLights = 9; int minDigitalOutputPin = 0;int maxDigitalOutputPin = 17; int randomDigitalOutput = 1; int numOfLightsToUse = 0; if(RandomNonBlockingDelay()) {TurnAllPinsOff(); numOfLightsToUse = int(random(minNumberOfLights, maxNumberOfLights + 1)); for(int i = 1; i <= numOfLightsToUse; i++) {randomDigitalOutput = int(random(minDigitalOutputPin, maxDigitalOutputPin + 1));digitalWrite(randomDigitalOutput, HIGH);}}}void sequence8() // sound to light{while (analogRead(soundpin) > 500){TurnAllPinsOn();}TurnAllPinsOff();} void TurnAllPinsOn(){ int minPin = 0; int maxPin = 17; for(int i = minPin; i <= maxPin; i++) { digitalWrite(i, HIGH); }}void TurnAllPinsOff(){ int minPin = 0; int maxPin = 17; for(int i = minPin; i <= maxPin; i++) { digitalWrite(i, LOW); }}bool RandomNonBlockingDelay(){int minTimeToDelay = 50; int maxTimeToDelay = 1000; if(currInterval <= 0 || prevMilliseconds <= 0){//Generate a new intervalcurrInterval = random(minTimeToDelay, maxTimeToDelay);prevMilliseconds = millis();return true;}else{long currMilliseconds = millis();if((currMilliseconds - prevMilliseconds) >= currInterval){currInterval = 0;prevMilliseconds = 0;return true;}elsereturn false;} }void loop(){ value = analogRead(selectpin);  if ( value <= 128 ){ sequence1(); }else if(value >= 129 && value <= 256){sequence2();}else if(value >= 257 && value <= 384){sequence3();} else if(value >= 385 && value <= 512){sequence4();}else if(value >= 513 && value <= 640){sequence5();} else if(value >= 641 && value <= 768){sequence6();}else if(value >= 769 && value <= 896){sequence7();}else //For any value >= 897{sequence8();}}