The Ursa Major cluster of galaxies — III. Optical observations of dwarf galaxies and the luminosity function down to MR = –211