Tuesday, March 6, 2012

[arduino] Music to RGB with LOLSs

Just in case you guys wonder, the previous LOLSs suffers from oxidation, poor solder joints and frequent breakdown with intermittent connectivity. Lih Sheng + helmi had kindly solder another piece of it for my use. Not to forget Kay Jin for helping to fix the broken leads on the RGB LEDs . Thanks!~

As of the previous challenge #3 posted to the lads and lasses to make the RGB LED change colour according to music, sadly none came forward and show me their stuff! Why I got to do everything myself
:(

update Sept 2012 this project was incorporated on a headphone and featured at Singapore Maker Faire


Time is a rare commodity. It is very difficult to prioritize which should come first (interest, hobby, $, love, life, work). So to save time, we should reuse as much as possible of what the stuff we had done previously!

If you guys could still recall my Arduino VU spectrum analyzer with FFT using LOL shield, courtesy of Andy Doro. Ready code are available for converting analog data on time domain to frequency domain.

The tricky part is actualy "mapping" the amplitude of each frequency bands (14 bands in total, coded for the LOL shield) and for all of the frequency bands into RGB. To further make the matter more complicated, Amplitude transition within each frequency band should be represented with the intensity/lumen of the RGB via the use of PWM, follow by hue/fading when transition in-between frequency bands.  Courtesy of "akgraphics" for the hue controlled RGB, my this experiment was made slightly easier......

In other words, my idea is to
1. Arrange the frequency bands into 3 "groups", low mid and high frequency and "map" into R, G then B.
2. Amplitude of each frequency band would translate into the brightness/intensity of each colour using PWM
3. Cycling from one frequency band to another, the R<->G<->B would "fade" by changing the hue of each colour.

Now, for the connection part
Using a 3.5mm" stereo jack to tap audio signal from computer/smart phone into A0 of arduino.
PWN pin 9,10,11 are use for controlling the RGB. LOLSs (it has a darlington IC) is used to "switched" 12v for the RGB LED strip with PWM.




 Just a point to note, test your RGB LED first. One of the RGB LED is not functioning properly when the pin for Red is held logic high. Time to get more RGB LED strips.








SWEEEET! Not bad for the first iteration.


If you have notice from the video, the "mapping" of sound frequency to RGB is not ideal. I get mostly RED, yes RED LIGHT. It is going to be any EYE SORE if I would stick this LED strip on my cheapo headphone as a bling bling. More time is needed to discover the relationship between the frequency appeared in music and the relevant colour to represent it (through code, that is). *hint: use the serial monitor* Another thing to note, how to repackage it so small (code size is 6k only), easy to retrofit on existing headphones (I DIZZ pseudo DR.Dre beats/senheizer), battery operated etc. Did I mentioned $$$ making?! LOL

Here comes the SUGAR. It can be intimidating, but the comments should make you feel at ease. Feel free to use/modify and let's ROXXX! Share your findings. A ping on new discoveries are much appreciated.

Saturday, February 18, 2012

[wares]

Still remember my HDD hack back in 2009?

Last tuesday, my E8410 suffered a BSOD then followed by a core dump.
It din't managed to reboot after all that. Can't even complete the POST (Power On Self Test)

I have tried various troubleshooting sequence, trying to isolate the problem.
1. Ram, by swapping fresh rams.
2. Pull out the hdd and CDrom just to boot from bare machine

It has beeping sounds, with various sequence.
1 long 2 short
1 long 3 short
4 short
=============================================

FML, time to waste $$$ again.

Tuesday, February 14, 2012

[game] Shogun2 Legandary difficulty level for Tokugawa clan pt2

Perseverance my friends. After countless events of total annihilation by my rival daimyos', my army turned against me, rebellion created by enemy monks. I survived until turn 220.

The methodologies to win the war are rather idiosyncratic. War is all about money and economics. 

My shogunate could not progress at the tech tree at a faster pace then my rivals. Hence my soldiers are mainly regular yari ashigaru and bow ashigaru with the exception few units of sword samurai. My castles are 2 level below my rivals and the production speed of my soldiers are rather limited. Most of the time, my army was outnumbered. I learned to let go my ego of banging head on with the hardened enemy and circumvent them using my newly devised methods. 

Having said that amassing a large fleet of ships, large contingent of army and agent units are very taxing on the finance for the rival state. I make a good guess on the financial status and the rice supply status. At every turn, maybe my rivals are not making enough profit to cover the new army created.  

If you guys could recall months back game play at turn 45, I have a couple of metsuke (secret police) running around, coupled with some monks and ninjas. 

My metsukes' was leveled up regularly by apprehending rival agent units at each and every turn. The success rate of apprehending grow slowly from 20% to 95%. While level up, I would choose to develop the bribery skill to the highest level. Usually, the apprehending would be successful, because Tokugawa clan specialty have a +2% of success rate.

I did level up my ninjas' too. Sabotaging rival rice plantations at every turn. This would decrease the rice supply by -1. Beside rice plantations, structures such as castle gate, rice merchant, tea house are possible targets too. If rival army are marching near to my territory, my ninja would sabotage the army to buy me time to lay an ambush. The skill sets of the ninja are build towards the "Ninjutsu" at level6. After my ninjas were leveled up, I start the process of assassinating rival generals, to make the rival army bare naked without the positive influence of a general. 

As for my monks, I send them far back into enemy lines, creating rebellion at poorly garrison castle. Of course, along the way I would use my monks to convert the enemy agent units.

The above 3 steps requires very little money to sustain. The bulk of my profit goes to building elite shock troops. It really took a very long time to build army that are truly useful. 

With my newly acquired army, sufficiently trained agent units and MONEY. The journey of clearing the Hatakeyama clan eastwards begin. At that point of time, having war at both sides of my border is a strict no no to the financial status. At the west borders, I have my agent units sabotaging enemy army and preventing them from marching to my land. At the east borders, my army is still outnumbered by the rivals. Good thing is, not every army are lead by a general. I would use my metsuke to attempt to bribe this category of army. Once successful, I would march my army near to this newly acquired army and enter battle with the rival and try to outnumber them. Once the enemy retreat or loses the battle, I attack the castle and loot the castle. Looting gave my shogunate a 20K income. Remember to set the newly acquired castle to no tax and put a metsuke to oversee the town, just in case of rebellion. 

With the new money, I could attempt to bribe more army. Some army are lead by general. Simple, send in the ninja to attempt assassination. If successful, send in the metsuke to bribe. If successful again, merger the new army with the current ones I have. Send in a ninja to sabotage the castle gate before sending in the merged army of mine. If successful, loot the castle. My rival clan recruited super elite units such as Bow hero, Sword Hero, Yari Hero, Great Guards and more. Bribing this army would make this units at my disposal. Indirectly, my army get level up without upgrading my castle facilities. 

The cycle repeats itself again. With some variations along the way of course.




revenge is sweet.
Game statistics suggesting the gruesome path that leads to the rising of my Tokugawa clan. 

I have created 4 vassal states, just to trade with. Trading will increase the financial profit. Occasional rebels were created by my monks. Then I would send in my generals to put out the rebellion. Indirectly, my generals get to level up!

The characteristic of the Tokugawa clan requires the training of the arts, rather than bushido.

Taxes are on the high side, but the populations are happy! Just train the Daimyo with lots of honour.

One of my awesome general with the traits of "Intimidating"

One of my awesome army with awesome agent units.

Check out my save game

Tuesday, February 7, 2012

[Arduino] 4x4x4 LED cube

I was really caught up with work, as always but I will try to update as frequent as possible.

back in 2009, I came across the idea of making 3x3x3 LED cube as part of the teaching material for programming, electronics , and leading the concept to computer engineering.
http://shin-ajaran.blogspot.com/2009/06/diy-3x3x3-led-cube.html

Now at late 2011/ early 2012 one of my project students, Eagle. He picked up the idea and superseded my 3x3x3 with his creation of 4x4x4 LED cube with some really awesome electronics circuit skills and soldering skills... that is soldering of 48LEDs into 3 layers, each layer consist of 16LEDs, with a XYZ+ (I lost count of it) solder joints.  IMBA!! To make life easier he is making this into an arduino shield for those that are interested to pick it up easily (minus the hassle of soldering, just plug and play).



Now hook it up to the arduino microcontroller. 4pins to control the layers , 4+4 pins to control the individual LEDs at each layer, 4 analog pins to control the dimming effect. Displaying of patterns on the LED cube requires the idea of refreshing the pattern at a high speed, to give human an illusion that there is animation. In actual fact, the LED just took turn to light up, one by one. 

now, code time. This code can be quite scary, looking at the binary pattern used to display the led pattern and using progmem to store the "animations". The code was adopted from an instructable.


The end product is totally worth the hours put in to this pet project! Check it out~


Next stage, would be modifying the circuit to use LED driver chip MAX7221. Luckily I bought some during my last visit to Shen Zhen.

I brought this LED cube around, like a young boy showing off his geeky toy. Upload to my facebook account just to attract some interest.... Little did I know, one of my programming class student surfaced with his 3x3x3 LED cube that he has made.... And the voyage to kernel begins...
check this out yo!

Friday, January 6, 2012

[FYP] Engineering Show 2012

My projects running Engineering Show 2012

Project: Interactive Video Wall


Project: Cloud Computing Software Loan Portal


Project: DIY PRT