Tuesday, July 17, 2012

Repairing an Under-Cabinet TV

After a thunder storm that briefly knocked out the power I found that the TV we have in our kitchen would not turn on. When the power button was pressed it seemed to power up for a short time then immediately turn off. I had seen similar behavior to this before on other devices with damaged power supplies so I figured why not take it apart and see if there was anything obviously damaged that could be replaced.

I got out a screw driver and opened up the case. The brown power supply board was easy to get to and check out. It's kind of difficult to see in the picture, but I immediately noticed a suspect capacitor with a bent up top. I plugged the TV up and turned it on and sure enough I noticed a high pitched hiss coming from around the capacitor.
At this point I was fairly certain that capacitor was the problem. Still, I decided to remove the board and give it a proper going over.
I managed to find some interesting "manufacturing techniques" we'll call them, but nothing that would inhibit the TV's function.
Since I had a spare capacitor of the same value conveniently lying around, I decided to go ahead and replace the one I suspected of being damaged. With a little solder wick I managed to remove the faulty component and replace it with a nice new blue capacitor.
 After placing the power board back in the case I plugged the TV into the outlet and pressed the power button and sure enough it was working again! All that trouble from such a small component...

Tuesday, July 27, 2010

Really Simple Random Image Using PHP

A popular effect on many websites is a random image that appears every time a page is reloaded. A recent project of mine required this effect on the homepage of the website, so I developed this really simple script using PHP.
Begin by placing the following code at the top of your page:
<?php 
$image_array[0] = "image1.jpg";
$image_array[1] = "image2.jpg";
$image_array[2] = "image3.jpg";
$image_array[3] = "image4.jpg";
$image_array[4] = "image5.jpg";

$random = rand(0, count($image_array) - 1);
?>

In the code above, I am assigning the image names I want to cycle through to an array. Next, I assign a variable to be my random number in the range zero to the last index in my array.

Now, go to the area in your HTML code where your images should be and make the image tag look as follows:
<img src="_images/<?php echo($image_array[$random]); ?>">
This should be pretty easy to understand; I'm simply filling the source attribute of the image tag with one of the names of the images from the array indexed by the random number I generated earlier in my code.

Like I mentioned earlier, this is a very simple script, but it achieves the result! To see this script in action, visit The Royal Closet website and refresh the homepage a couple times.