A polyacrylamide hydrogel with copper nanoparticles inside is able to determine glucose levels in a sample added to the gel. As phenylboronic acid groups on the hydrogel polymers bind the glucose molecules, the gel becomes swollen. As a result, the copper nanoparticles move apart, changing how incident light is diffracted by the gel. As the glucose levels decrease, the color of gel changes from red to orange to yellow to green.