That's an interesting question. Let's look at its two parts: copyright and patents.
An invention on its own cannot be protected by copyright. However, if an author included considerable detail about some novel machine or process in a literary work, it may well be protected by copyright to the extent that it formed a substantial part of the work concerned. But that would not prevent someone actually constructing a machine etc which did what the author had described. To take a real example, in The Disintegration Machine
, the author Arthur Conan Doyle described a machine capable of 'dis-integrating' objects or people and then re-assembling them. Since the machine is central to the story it would probably be an infringement of copyright (if the published works of Conan Doyle were still in copyright, which they aren't) for someone else to write a story which also featured the disintegration machine that Conan Doyle described, but there would be no objection to someone inventing or building such a thing in real life. In fact of course the transporter in the Star Trek TV series and films, is very similar to Conan Doyle's machine.
So from the point of view of you writing a story which featured someone else's fictional creation, you would need to be careful not to re-use too much detail from the original story, unless the idea itself was widely used amongst other writers in the same genre. The more central the invention is to the essence of the story, the greater the risk that copying it would amount to infringement. That said, the UK courts tend to take a broader view of what constitutes a substantial part when considering individual plot or character details, compared to the US courts which recently held that the Batmobile
from the US TV series was a protected 'character'.
As for an invention protected by patent, you should be fairly free to incorporate it in a work of fiction because the Patent Act only prevents the making or importation of an actual product subject to patent, or if it a process, use of the process, without authority.
I hope this answers your question.