How to make a barcode like stripes texture
Shady's Answer works only in this scene and not only in all,So you will have to edit values per scene.

And that's why I prefer using some math Instead.

To get information about our object we will use the texture coordinates node,and use Generated coordinates.

Suppose you want the strips to be vertically,then you should use the Z axis only of the coordinates and that is by using Separate XYZ node.

Now let's do the math,I will first multiply the Z axis by a variable integer which is equal to the number of black or white strips.

Then I will Modulo the result by 1,Which means I repeat the gradient every 1,and since we multiplied the axis by "say 5" then we will repeat 5 times.

Now we have a number of gradients,I will limit them to be either white or black using Greater than node.

Here the node tree:


Which will produce the following result:



I can group it and expose the variable,and we got our node group: