The purpose of a g-switch in a rocket control is to activate a recovery, flight control or recording systems automatically at the moment of launch. It is a good practice to incorporate some sort of g-switch into a rocket system as it greatly simplifies the launch procedure.
Several manufactures supply g-switches of different dimensions and G-rating. However, their price remains relatively hight comparing to other electronic components. Cheaper alternatives can be found. One of them is presented here.
The picture below shows a switch salvaged from an old CD-ROM.
The spring loaded lever rotates in both directions connecting the centre three terminals to either left of right terminal (on the picture). A mass-force of about 23 grams applied to the centre of the flat part of the lever is required to connect the terminals.