I only have 2 black wires and 1 white. The digital timer has 1 red,1 blue,1 black and 1 green. I connected my 2 black wires to black and blue accordingly, and the white to white. My timer turned on and I was able to set the time and programmed it to my set on and off time. Unfortunately, it didn't do what it supposed to do.What did I do wrong? Is it a wiring or a programming problem? Please help.
The red wire should be capped in the box, it is not needed in a single pole switch application.
The black of the timer needs to go to the line side black wire (the hot). The blue of the timer needs to go to the load side black (the switch leg). It is possible if you have 2 blacks in the switch box, that you got the two switched. If you have a voltage tester/meter you can check which black has voltage to neutral or ground. The black with voltage is your hot.
You could also just swap the blacks and wait to see if that fixes your problem.