In the previous post, I had talked about how a digital photograph is stored in the computer. In this post, I will talk about how a digital photograph senses the photograph talking only about the essential components (using description for RGB colors). A modern digital camera has far more advances than the simplistic picture explained here.
A digital camera has a number of lenses which focus light onto chips that are sensitive to incoming light. In the market, there are two types of image sensors - charge-coupled device (CCD), and the Complementary Metal Oxide Semiconductor (CMOS). CCDs  are far more popular than CMOS chips because they are considered to be affected by noise to a lesser extent (and I will use CCDs to explain how a digital camera works). The role of this chip is to sense the light that comes in and convert the light energy to an electric signal that is amplified and then digitized and finally processed.
How a CCD works? Photoelectric effect  is the property by which some metals emit electrons when light shines on them. The CCD in the digital camera is a silicon chip that is covered with a grid of small electrodes called photosites. One photosite corresponds to each pixel.
Before a photo is taken, the camera charges the surface of each photosite with electrons. When light strikes a particular side of the photosite, the metal at that site releases some electrons, which travel to the opposite end of the site (forming what is commonly called the capacitor). The larger the intensity of the light that falls on it, the larger the number of electrons that are released, and hence larger the voltage that develops across the photosite. The voltage is then converted to a number using an analog-to-digital converter that corresponds to the intensity of the light that falls on that site. This takes care of the intensity, but we have not discussed about how the photosite knows the color of the light.
As discussed earlier, the color of a pixel is formed by mixing red, green, and blue colors (RGB). So all the light does not hit each photosite, but rather, there is a filter placed on top of the photosite that only lets red, green, or blue color through. Hence, depending on what color is through, each photosite only measures the intensity of the red, green, or blue color that falls on it, and no other color. After this, to measure the intensity of green and blue colors on a site with a red filter, an interpolation algorithm (a process called demosaicing) is used that approximates the intensity of the blue and green light on that site using the intensity of these colors in the neighboring sites.
Lastly, as green is in the center of the spectrum in the visible light (VIBGYOR), our eye is better at picking up different shades of green, and hence, there are a larger number of photosites that sense green light than blue or red. The Bayer pattern shown below is the most common arrangement of photosites in a single array CCD chip.
The other end of expensive digital cameras (read 10's of thousands of dollars) have multiple arrays and avoid the interpolation step. So the incoming light could be split into three copies and then passed through three separate filters and three different arrays and sensed separately to make the final picture by merging these readings together.
There are more complications that arise even in the simple camera, but maybe another post to deal with them (but no promises as I got to do some research before I can post myself).
 CCDs were invented by George Smith and Willard Boyle at the Bell Labs.
 Albert Einstein won the Nobel prize in 1921 for the quantum explanation of photoelectric effect.
The source for most of this stuff is Chapter 2 of the Third Edition of the Complete Digital Photography by Ben Long, though the mistakes here are probably mine.
For further reading:
How Stuff Works answers how a camera works
How an image sensor works?
CCD vs CMOS
Wikipedia's CCD entry