updated to work with arduino, with few mods