Whether or not computers or robots can gain consciousness isn't as easy a question as you might think. There is still much we don't know about human consciousness. While programmers and computer scientists create algorithms that can simulate thinking on a superficial level, cracking the code necessary to give consciousness to a machine remains beyond our grasp.
Part of the problem lies with defining consciousness. Eric Schwitzgebel, professor of philosophy at the University of California, Riverside, suggests that the concept is best explained through examples of what consciousness is and what it isn't. Schwitzgebel says that vivid sensations are part of consciousness. You could argue that through sensors, robots and computers can experience -- or at least detect -- stimuli that we would interpret as sensations. But Schwitzgebel also points out other instances of consciousness: inner speech, visual imagery, emotions and dreams are all elements we can experience that machines can't.
Not all philosophers agree upon what is and isn't consciousness. At best, most agree that consciousness rests in the brain. But we don't fully understand the mechanisms that provide consciousness.
Without this understanding, it may be impossible to endow machines with consciousness. It's possible to create programs that mimic thought. These programs might give a machine the ability to recognize and respond to patterns. But ultimately, the machine isn't aware of itself. It's simply responding to commands.
Neurologists and computer scientists could conceivably create an artificial model of a human brain that might produce consciousness. The problem these scientists face isn't trivial. Since we don't have a full understanding of how the brain works, building an artificial version might not be adequate to create actual consciousness.
Despite the challenges, there are teams of engineers and scientists around the world working toward artificial consciousness. It remains to be seen if we'll ever achieve this goal. But assuming we did find a way to give machines consciousness, what happens then?