Proper way of attaching bones to the model
The automatic weights calculation takes normals into consideration. Since you joined multiple meshes together, typically the normals become inconsistent.

What you need to do is go into edit mode, hit Mesh - Normals - Recalculate Outside. Then unparent the mesh (Alt+p), remove the armature modifier, and do it again (select mesh, select armature, Ctrl+P with automatic weights).

Also another method is leave all meshes separate, and parent each piece to a bone (select mesh, select bone in pose mode, ctrl+p and select bone), which is good for mechanical type armature deform. The downside to this is I find this method VERY slow in game engine if you are using that.