Average speed cameras were first installed on Spanish roads in 2010. They are not just features on motorways. You can also find them on dual carriageways as well as conventional two way roads.
A number of cameras work together and will calculate the average speed over a certain distance of the road. When you pass the first set of cameras your registration number is recorded. Then when you reach the end of the designated section of the road being checked you will pass the second set of cameras. This second set of cameras will again record your registration number. The system then calculates your average speed to see if you have exceeded the speed limit.
You need to have past both sets of cameras for the system to calculate your average speed. It does not matter if you change lanes as the cameras are linked together.
The sections of the road where these average speed cameras in Spain are placed will be indicated clearly by signage similar to that pictured.
If you are caught, then you could receive a fine and possibly penalty points as well.