A pen-and-electronic device assembly comprises: a barrel; a writing
member; and an electronic device. The electronic device includes: a
housing having a battery-mounting part including top and bottom walls and
a peripheral wall cooperating with the top and bottom walls to define an
enclosed battery compartment, the peripheral wall including a first
portion fixed to the top and bottom walls and defining an access opening,
and a second portion connected detachably to the first portion for
covering the access opening; and a circuit unit in the housing. The
second portion is fastened to the bottom wall so as to prevent undesired
access to the battery compartment.