Answers.Body: <p>LEGO Dimensions had NFC tags in the round bases, e.g. <a href="https://www.bricklink.com/v2/catalog/catalogitem.page?P=18605c01pb01" rel="noreferrer">part 18602c01 &quot;Dimensions Toy Tag 4 x 4 x 2/3, generic&quot;</a>:</p>
  <p><a href="https://i.sstatic.net/tE5eC.png" rel="noreferrer"><img src="https://i.sstatic.net/tE5eC.png" alt="round plate with NFC tag" /></a></p>
  <p>These can be integrated into the accessories. The tag, and therefore the accessory, can be identified using a 3<sup>rd</sup> party NFC reader.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-25T09:00:09.810Z
Answers.LastActivityDate: 2023-01-25T11:45:08.053Z
Answers.LastEditDate: 2023-01-25T11:45:08.053Z
Answers.UserDisplayName: zovits
Answers.Body: <p>If you wanted an entirely Lego based solution, <a href="https://www.lego.com/en-nz/product/boost-creative-toolbox-17101" rel="nofollow noreferrer">Lego Boost</a> has a colour sensor part <a href="https://www.bricklink.com/v2/catalog/catalogitem.page?P=bb0891c01&amp;name=Electric%20Sensor,%20Color%20and%20Distance%20-%20Boost&amp;category=%5BElectric%5D#T=C&amp;C=1" rel="nofollow noreferrer">6182145</a> that can detect colour and is, I think, compatible with the EV3 <a href="https://www.lego.com/en-nz/themes/mindstorms/about" rel="nofollow noreferrer">Mindstorms sets</a> controller as well as the Boost controller. The EV3 apparently also has a colour sensor (and an IR sensor) in the basic kit, but I've not used them. I don't know if any of these are compatible with devices like the Arduino (depends on the connectors I would think), but it looks like a modified ethernet-style port for the I/O. You could potentially daisy-chain a Pi and the mindstorms hub, using the Pi to program the mindstorm.</p>
  <p>If you have colour coded accessories, these options could tell you if they are present and which ones are present.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-24T23:33:27.367Z
Answers.LastActivityDate: 2023-01-24T23:33:27.367Z
Answers.UserDisplayName: bob1
Answers.Body: <p>I'll suggest going the Arduino way and relying on <a href="https://www.adafruit.com/product/375" rel="nofollow noreferrer">magnetic contact switches</a> - fairly inexpensive, and invisible once embedded in a build.</p>
  <p>Another commonly used trick is using an <a href="https://www.adafruit.com/product/4007" rel="nofollow noreferrer">ultrasound distance sensor</a> on the receptacle - the distance will be (near) zero if there's anything attached.</p>
  <blockquote>
  <p>Are there any standard bricks with contacts built-in[?]</p>
  </blockquote>
  <p>Yes - the <a href="https://brickipedia.fandom.com/wiki/9V" rel="nofollow noreferrer">9V system</a> which started in the late 80s featured 2x2 plates with conductive metal inserts, e.g. <a href="https://www.bricklink.com/v2/catalog/catalogitem.page?P=5306bc011" rel="nofollow noreferrer">part 5306bc011 &quot;Electric, Wire with Brick 2 x 2 x 2/3 Pair, 11 Studs Long&quot;</a> (besides battery packs, train motors and lights):</p>
  <p><a href="https://i.sstatic.net/YSCdl.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/YSCdl.png" alt="9V wire with connector plates" /></a></p>
  <p>Note that:</p>
  <ul>
  <li>Each wire is connected to both two studs on the top and two antistuds on the bottom, and</li>
  <li>9V-compatible parts are not being manufactured anymore, and therefore are only available in the aftermarket</li>
  <li>Any 9V parts in the aftermarket are <em>at least</em> a decade old, and cables are subject to wear&amp;tear.</li>
  </ul>
  <p>Since you are not afraid of using glue, and <strong>if</strong> you're keen on going the &quot;closing an electric circuit&quot; route, you might instead want to use copper foil tape (which should be readily available at crafts stores), or even <a href="https://en.wikipedia.org/wiki/Conductive_ink" rel="nofollow noreferrer">conductive ink</a>.</p>
  <p>Finally, if you want an unconventional approach with contemporary available parts, you can always use <a href="https://bricks.stackexchange.com/questions/15367/">Mario pants</a>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-24T17:14:35.177Z
Answers.Text: This is where the "Mario pants technique" was invented.  I'm proud to be a witness.  :)
Answers.UserDisplayName: chicks
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-24T21:05:59.750Z
Answers.Text: There were also non-train 9V parts with contact bricks.  I have a couple of steady/flashing lights (cleverly, depending which way round you attach them), a siren, and a battery box, plus the bricks. (Late 80s I'd guess).  More recently there are Technic sets with wires that use bricks as plugs.  We have [42095](https://www.lego.com/en-gb/product/remote-controlled-stunt-racer-42095) for example, and I know there are other more complex uses
Answers.UserDisplayName: Chris H
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-25T10:09:25.970Z
Answers.Text: Worth mentioning that the 9V wires are also _very_ prone to literally falling apart. The majority of wires on bricklink suffer from deteriorating rubber coatings, to the point where slightly bending the wire is enough for the rubber to chip completely off.
Answers.UserDisplayName: Tuzi
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-25T10:38:55.050Z
Answers.Text: I added some of that into the answer. To be fair, OP asked if there are any parts *at all*, but didn't ask about the reliability of said parts :-D
Answers.UserDisplayName: IvanSanchez
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-30T15:14:58.167Z
Answers.Text: Thanks for your comprehensive help! I will try to start with foil tape or magnetic switches.
Answers.UserDisplayName: Norbert
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-24T09:48:24.527Z
Answers.LastActivityDate: 2023-01-25T10:37:15.987Z
Answers.LastEditDate: 2023-01-25T10:37:15.987Z
Answers.UserDisplayName: IvanSanchez
Body: <p>I want to build a model of a complex machine with Lego and Arduino or a Raspberry. The machine model also features several accessories that can be added or removed during operation of the machine which influences its behavior. I plan to glue together the accessory bricks. My goal is to detect if that accessory is present on the machine or not.</p>
  <p>Are there any standard bricks with contacts built-in, or do I have to make them myself somehow?
  (NFC/RFID would also work but the simplest solution will do it)</p>
  
Tags: <piece-information><electronics><3rd-party><arduino>
Title: Recommendation on how to build a "brick presence detector"?
UserDisplayName: Norbert
ThreadText: # Recommendation on how to build a "brick presence detector"?
  
  (Asked by: username_0 on 2023-01-24)
  
  I want to build a model of a complex machine with Lego and Arduino or a Raspberry. The machine model also features several accessories that can be added or removed during operation of the machine which influences its behavior. I plan to glue together the accessory bricks. My goal is to detect if that accessory is present on the machine or not.
  
  Are there any standard bricks with contacts built-in, or do I have to make them myself somehow?
  (NFC/RFID would also work but the simplest solution will do it)
  
  **Tags:** piece-information, electronics, 3rd-party, arduino
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_3 on 2023-01-24. Score: 8 | Accepted answer
  
  I'll suggest going the Arduino way and relying on [magnetic contact switches](https://www.adafruit.com/product/375) - fairly inexpensive, and invisible once embedded in a build.
  
  Another commonly used trick is using an [ultrasound distance sensor](https://www.adafruit.com/product/4007) on the receptacle - the distance will be (near) zero if there's anything attached.
  
  > Are there any standard bricks with contacts built-in[?]
  
  Yes - the [9V system](https://brickipedia.fandom.com/wiki/9V) which started in the late 80s featured 2x2 plates with conductive metal inserts, e.g. [part 5306bc011 "Electric, Wire with Brick 2 x 2 x 2/3 Pair, 11 Studs Long"](https://www.bricklink.com/v2/catalog/catalogitem.page?P=5306bc011) (besides battery packs, train motors and lights):
  
  [![9V wire with connector plates](https://i.sstatic.net/YSCdl.png)](https://i.sstatic.net/YSCdl.png)
  
  Note that:
  
  * Each wire is connected to both two studs on the top and two antistuds on the bottom, and
  * 9V-compatible parts are not being manufactured anymore, and therefore are only available in the aftermarket
  * Any 9V parts in the aftermarket are *at least* a decade old, and cables are subject to wear&tear.
  
  Since you are not afraid of using glue, and **if** you're keen on going the "closing an electric circuit" route, you might instead want to use copper foil tape (which should be readily available at crafts stores), or even [conductive ink](https://en.wikipedia.org/wiki/Conductive_ink).
  
  Finally, if you want an unconventional approach with contemporary available parts, you can always use [Mario pants](https://bricks.stackexchange.com/questions/15367/).
  
  > **Comments:**
  > **username_4**: This is where the "Mario pants technique" was invented.  I'm proud to be a witness.  :)  
  > **username_5**: There were also non-train 9V parts with contact bricks.  I have a couple of steady/flashing lights (cleverly, depending which way round you attach them), a siren, and a battery box, plus the bricks. (Late 80s I'd guess).  More recently there are Technic sets with wires that use bricks as plugs.  We have [42095](https://www.lego.com/en-gb/product/remote-controlled-stunt-racer-42095) for example, and I know there are other more complex uses  
  > **username_6**: Worth mentioning that the 9V wires are also _very_ prone to literally falling apart. The majority of wires on bricklink suffer from deteriorating rubber coatings, to the point where slightly bending the wire is enough for the rubber to chip completely off.  
  > **username_3**: I added some of that into the answer. To be fair, OP asked if there are any parts *at all*, but didn't ask about the reliability of said parts :-D  
  > **username_0**: Thanks for your comprehensive help! I will try to start with foil tape or magnetic switches.  
  
  ---
  
  ### Answer by username_1 on 2023-01-25. Score: 7
  
  LEGO Dimensions had NFC tags in the round bases, e.g. [part 18602c01 "Dimensions Toy Tag 4 x 4 x 2/3, generic"](https://www.bricklink.com/v2/catalog/catalogitem.page?P=18605c01pb01):
  
  [![round plate with NFC tag](https://i.sstatic.net/tE5eC.png)](https://i.sstatic.net/tE5eC.png)
  
  These can be integrated into the accessories. The tag, and therefore the accessory, can be identified using a 3rd party NFC reader.
  
  
  ---
  
  ### Answer by username_2 on 2023-01-24. Score: 3
  
  If you wanted an entirely Lego based solution, [Lego Boost](https://www.lego.com/en-nz/product/boost-creative-toolbox-17101) has a colour sensor part [6182145](https://www.bricklink.com/v2/catalog/catalogitem.page?P=bb0891c01&name=Electric%20Sensor,%20Color%20and%20Distance%20-%20Boost&category=%5BElectric%5D#T=C&C=1) that can detect colour and is, I think, compatible with the EV3 [Mindstorms sets](https://www.lego.com/en-nz/themes/mindstorms/about) controller as well as the Boost controller. The EV3 apparently also has a colour sensor (and an IR sensor) in the basic kit, but I've not used them. I don't know if any of these are compatible with devices like the Arduino (depends on the connectors I would think), but it looks like a modified ethernet-style port for the I/O. You could potentially daisy-chain a Pi and the mindstorms hub, using the Pi to program the mindstorm.
  
  If you have colour coded accessories, these options could tell you if they are present and which ones are present.
  
  
  ---
  
  