Thanks for the help, especially the tip to use the millis function, my programme now works perfectly.