A microfluidic device for preparing a mixture, has a mixer. The mixer includes a plurality of chambers, each chamber having a volume of at most 1 microliter, a first plurality of channels, each channel fluidly connecting 2 chambers, a plurality of chamber valves, each chamber valve controlling fluid flow out of one of the plurality of chambers, and a first plurality of channel valves, each channel valve controlling fluid flow through one of the first plurality of channels.