When a car crashes, it starts to lose speed very rapidly. An accelerometer detects the change in speed and if it is great enough, it triggers the airbag circuit by passing an electric current through a heating element. This ignites a chemical explosive that generates a massive amount of harmless gas
to read this article and more!