Breaking point of pencil

Hi, I’m looking to write a code where a warning light will switch on just before a pencil is about to break when a force is applied at the middle. Could anyone direct me to the right component to achieve this? Would it be a flex sensor or some other form of force sensor? Any help would be appreciated. Thanks

I think you're asking what is the right type of sensor and the only way I can see to find that is by trial and error. Depending how accurate you need it to be you could measure force (having previously measured how much force it takes to break the pencil) or deflection (having decided how much deflection is normal before the pencil breaks) or sound (having found out how to identify the cracking noises that precede a complete failure).

so you are not referring to the pencil lead? maybe you can set an experiment. put slotted weights on the pencil and see roughly around how much weight is needed to break the pencil or to the point in which it is bout to break. use this value as a guide. maybe you can add pressure plates at the end of the pencil and when the value of the point of break approaches the critical point , a light will lid up. just a suggestion haha