<p>In my program, I need to detect if a touch sensor is activated. Here's some of my code:</p>

<pre><code>var nxt = new Brick&lt;Sensor, Sensor, Sensor, Sensor&gt;("usb");
nxt.Connection.Open();
nxt.Sensor1 = new TouchSensor();
nxt.Sensor1.Reset(false);
nxt.Sensor1.Initialize();
Console.WriteLine(nxt.Sensor1.ReadAsString());
</code></pre>

<p>But When I run it, the value always displays as zero. But I discovered that if I go into the "View" menu in the NXT and see the touch sensor value, the program value reads 1. I can't do that. Also, don't tell me to use Bluetooth, or get the EV3, because I can't. I've tried using the code from the Monobrick website, still nothing. I've also asked it in the "robotics" section. Can someone help me?</p>

CC BY-SA 3.0
2017-02-19T23:02:31.907Z
This got answered over at http://robotics.stackexchange.com/questions/11599/monobrick-communication-library-reading-nxt-sensors
chicks
CC BY-SA 3.0
2017-02-19T23:03:39.593Z
I didnt get my problem fixed
jpcreeper13
<nxt>
Reading NXT Touch Sensor with Monobrick Communication Library
jpcreeper13
# Reading NXT Touch Sensor with Monobrick Communication Library

(Asked by: username_0 on 2017-02-18)

In my program, I need to detect if a touch sensor is activated. Here's some of my code:
var nxt = new Brick("usb");
nxt.Connection.Open();
nxt.Sensor1 = new TouchSensor();
nxt.Sensor1.Reset(false);
nxt.Sensor1.Initialize();
Console.WriteLine(nxt.Sensor1.ReadAsString());

But When I run it, the value always displays as zero. But I discovered that if I go into the "View" menu in the NXT and see the touch sensor value, the program value reads 1. I can't do that. Also, don't tell me to use Bluetooth, or get the EV3, because I can't. I've tried using the code from the Monobrick website, still nothing. I've also asked it in the "robotics" section. Can someone help me?

**Tags:** nxt

> **Comments:**
> **username_1**: This got answered over at http://robotics.stackexchange.com/questions/11599/monobrick-communication-library-reading-nxt-sensors  
> **username_0**: I didnt get my problem fixed  

---

## 0 answers

