I want to make a box that holds bolts. But I want to display the number of bolts currently in the box with a display. So when you take a bolt out it will tell how many are left.

How can I do this.

Keep track of the weight of the box. Bolts have a known weight, yes?

(total weight - empty weight)/weight per bolt = numbers of bolts

Well, as long as the bolts are exactly the same.