The addmission fee for an exhibition was $8.50 for each adult and $3.50 for each pupil. A total of $5120 was collected. If 160 more pupils than adults visited the exhibition, how many pupils visited the exhibition?

Let's assume the number of adults who visited the exhibition is A and the number of pupils who visited the exhibition is P.

- The cost of each adult admission is $8.50, so the total cost for adult admission is 8.50A.
- The cost of each pupil admission is $3.50, so the total cost for pupil admissions is 3.50P.
- The total amount collected from the admission fees is $5120, so we have the equation 8.50A + 3.50P = 5120.

From the problem, we know that there were 160 more pupils than adults visiting the exhibition, so P = A + 160.

Substituting this value of P into the equation we have: 8.50A + 3.50(A + 160) = 5120.
Expanding and simplifying the equation, we have: 8.50A + 3.50A + 560 = 5120.
Combining like terms, we have: 12A + 560 = 5120.
Subtracting 560 from both sides of the equation, we have: 12A = 4560.
Dividing both sides of the equation the coefficient of A, we have: A = 4560/12 = 380.

Thus, the number of pupils visiting the exhibition is P = 380 + 160 = 540. Answer: \boxed{540}.