Introduction to riboswitches and function
A riboswitch is a region of a mRNA that can act like a switch to turn gene expression on or off. In the presence of a specific ligand, a riboswitch changes shape uncoupling the polymerase of the DNA. Polymerase is no longer able to transcribe thus terminating gene expression. Riboswitches are useful for gene regulation.
The mRNA has the ability to fold and base pair with itself forming different structures, such as those found on the regions that make up a riboswitch. Within a basic riboswitch, there are two main regions. One region binds to the ligand, also known as an aptamer. The second region is also known as a terminator hairpin and its existence is dependent on whether or not a ligand is bound to the aptamer. When a ligand binds to an aptamer it causes the aptamer to become more stable. Because a more stable aptamer region forms, the mRNA downstream from the aptamer undergoes a shape change and a terminating hairpin forms via mRNA base pairing with itself. In the event that a ligand has bound to an aptamer and a hairpin has formed, transcription is terminated by the uncoupling of the DNA polymerase. mRNA is transcribed until the polymerase reaches a polyuracil region down stream of the riboswitch. The polyuracil region is also known as a pause site because the polymerase tends to slow down as it passes through. The polymerase is knocked of the DNA by the hairpin as it reaches the polyuracil region and uncouples thus terminating transcription. If a ligand does not bind to the aptamer region, the polymerase will simply continue transcribing down the DNA strand and through the pause site. 
A little history
Riboswitches were first discovered around 2002. Metabolic pathways and such were noticed to change in the presence of certain chemistry such as vitamin B but it was not understood why this occurred and how it changed gene expression. It was discovered that vitamin B acts as a ligand and binds to the aptamer on the cobalamin riboswitch. With this discovery more naturally occurring riboswitches were discovered. The discovery of riboswitches allowed for a better understanding of how the RNA is able to regulate its own gene expression.
Types of riboswitches and surrounding conditions
Naturally occurring riboswitches usually terminate gene expression when bound by a ligand and have only two domains: an aptamer and a terminating hairpin. There are riboswitches that can turn gene expression on when bound by a ligand. 
Some riboswitches are not dependent on a ligand but rather temperature. An example is a magnesium transport protein riboswitch found in Salmonella enterica. When a certain temperature is reached, the cell experiences heat shock and transcription of the mgtA gene is turned on. Increased transport of magnesium is thought to have thermoprotective functions by diffusion of energy and oxygen thus protecting the cells membrane and proteins from denaturing. 
Like other molecules, riboswitches are sensitive to pH levels, salt concentration, and temperature.
DNT (2,4-dinitrotoulene) is used in the production of bedding and cushioning in furniture and is also an intermediate chemical in the production of TNT. DNT is hazardous and can contaminate bodies of water as well as soil. The detection of DNT is important to prevent contamination but also to detect unwarranted production of TNT.
E. Coli can be used to detect DNT by fluorescence. A fluorescence resonance energy transfer (FRET) riboswitch was created by placing eGFP (enhanced green fluorescent protein) and a REACh (Resonance Energy Accepting Chromoprotein) in combination along the mRNA strand with a TEV protease linking two proteins. In the presence of DNT the riboswitch is activated and the TEV protease is translated. The protease cleaves the link between eFGP and REACh thus allowing eGFP to become fluorescent. In this way, DNT can be detected by the fluorescence of E. Coli. 
Theophylline is useful in medicine and has anti-inflammatory effects is used for respiratory diseases.
iGEM team ZJU from China used a theophylline riboswitch to test the efficiency of different tunable scaffolds that contained allosteric sites. The team named these alloscaffolds “clovers”. The more efficient the clover, the more fluorescent the E. Coli in the presence of the ligand theophylline. 
The iGEM team at Imperial College at London discovered that an increase in theophylline transport rate and receptors increases the expression of the CheZ gene. CheZ has an affect on the way E. Coli swims thus by adjusting the theophylline levels the team was able to indirectly manipulate E. Coli’s swimming behavior. 
University of California Santa Barbara is working on a cocaine sensor that works like a breathalyzer. The detector consists of an electrode coated with molecules that are attracted to cocaine. If present, cocaine will bind to an aptamer changing the shape of the riboswitch. The new formation of the riboswitch allows electricity to pass freely through the riboswitch and the electrode. The electrode can be washed and reused up to 100 times however with each succession, the accuracy of the test drops by 1%. Scott Test is also able to sense cocaine through masking chemicals such as cobaltous thiocyanate which is commonly used by drug dealers too fool cocaine detectors. 
Stojanovic and coworkers created a synthetic aptamer that detects cocaine in 2009. In the presence of cocaine, the aptamer changes shape and turns transcription of fluorescent protein on. The aptamer is very specific to cocaine and does not bind to derivatives of cocaine thus giving very truthful results. 
- | Research | The Batey Laboratory | Robert T. Batey. (n.d.). Retrieved May 2, 2013, from http://chem.colorado.edu/bateygroup/research_2.html
- , M., & Breaker, R. R. (2004). Gene regulation by riboswitches. Nature reviews. Molecular cell biology, 5(6), 451–63. doi:10.1038/nrm1403
- , M., Findeiß, S., Weissheimer, N., Stadler, P. F., & Mörl, M. (2012). De novo design of a synthetic riboswitch that regulates transcription termination. Nucleic acids research, gks1330–. doi:10.1093/nar/gks1330
- ’Connor, K., Fletcher, S. A., & Csonka, L. N. (2009). Increased expression of Mg(2+) transport proteins enhances the survival of Salmonella enterica at high temperature. Proceedings of the National Academy of Sciences of the United States of America, 106(41), 17522–7. doi:10.1073/pnas.0906160106
- , M. E., Harbaugh, S. V, Chushak, Y. G., Stone, M. O., & Kelley-Loughnane, N. (2013). Development of a 2,4-Dinitrotoluene-Responsive Synthetic Riboswitch in E. coli Cells. ACS chemical biology, 8(1), 234–41. doi:10.1021/cb300274g
- , P., Bernal-Perez, L. F., Annunziata, O., & Ryu, Y. (2012). Rationally-designed fluorescent lysine riboswitch probes. Organic & biomolecular chemistry, 10(39), 7872–4. doi:10.1039/c2ob26160j
- :Imperial College London/Extras/Collaboration - 2011.igem.org. (n.d.). Retrieved February 24, 2013, from http://2011.igem.org/Team:Imperial_College_London/Extras/Collaboration Team:ZJU-China/project s1 1.htm - 2012.igem.org. (n.d.). Retrieved February 24, 2013, from http://2012.igem.org/wiki/index.php?title=Team:ZJU-China/project_s1_1.htm&oldid=282374 Theophylline: MedlinePlus Drug Information. (n.d.). Retrieved February 24, 2013, from http://www.nlm.nih.gov/medlineplus/druginfo/meds/a681006.html
- , P., Jonsson, E. O., & Sigurdsson, S. T. (2009). Folding of the cocaine aptamer studied by EPR and fluorescence spectroscopies using the bifunctional spectroscopic probe Ç. Nucleic acids research, 37(12), 3990–5. doi:10.1093/nar/gkp277
- , B. S. (2011, December 6). Researchers Develop Portable Cocaine Detector | Fox News. Fox News. Retrieved from http://www.foxnews.com/story/0,2933,191662,00.html
- , M. N., & Landry, D. W. (2002). Aptamer-Based Colorimetric Probe for Cocaine. Journal of the American Chemical Society, 124(33), 9678–9679. doi:10.1021/ja0259483
- , S. C., & Koshland, D. E. (1987). Roles of cheY and cheZ gene products in controlling flagellar rotation in bacterial chemotaxis of Escherichia coli. Journal of bacteriology, 169(3), 1307–14. Retrieved from http://www.pubmedcentral.nih.gov/articlerender.fcgi?artid=211935&tool=pmcentrez&rendertype=abstract