To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.scoutOpen lugnet.robotics.scout in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / Scout / 206
205  |  207
Subject: 
Re: How to read the touch sensors on the Scout in NQC?
Newsgroups: 
lugnet.robotics.rcx.nqc, lugnet.robotics.scout
Date: 
Mon, 17 Dec 2001 11:22:40 GMT
Viewed: 
32 times
  
Juergen Stuber wrote:

Hi Chris,

Chris Barker <chris@superfami.com> writes:

#1 if ((SensorValueRaw(1) & SensorValueRaw(0)) != 255)


this is a bit crazy, unless your sensor value is a bit pattern.



That is what I thought, but it will determine if the touch sensor is
pressed.


#2 if ((SensorValueRaw(1) != 255) || (SensorValueRaw(0) != 255))


This is sensible, but are you sure it's ok to use equality
and not inequalities like SensorValueRaw(1) < 240?



Dunno, I'll try. Then again, if !=255 works...



Number two is obvious but rather verbose, number one is just wierd!


but it's equivalent, also in C, where & is bitwise and.


Since I'm accustomed to Perl which allows extreme lazyness I would have
thought that I could just do this:

if ((SensorValueRaw(1) || SensorValueRaw(0) != 255))

But that does not work. Is this normal in NQC?


Fortunately.

Jürgen "who thinks Perl is an abomination"


If it were not for Perl I'd never write a line of code ^_^



Message is in Reply To:
  Re: How to read the touch sensors on the Scout in NQC?
 
Hi Chris, (...) this is a bit crazy, unless your sensor value is a bit pattern. (...) This is sensible, but are you sure it's ok to use equality and not inequalities like SensorValueRaw(1) < 240? (...) but it's equivalent, also in C, where & is (...) (23 years ago, 16-Dec-01, to lugnet.robotics.rcx.nqc, lugnet.robotics.scout)

6 Messages in This Thread:


Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR