Logic opposite?

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
legostormrobot
Posts: 19
Joined: 12 Jul 2012, 17:48

Logic opposite?

Post by legostormrobot »

Ok, I'm now wondering how to make something that could be called an opposite block. So say I have an rotation sensor reading going into a variable. If that variable reads forward (I'm assuming yes or 1), how could I wire it to a motor block to make it go reverse (maybe no or 0?)? I'm assuming it would have to do with a logic block...
Noah Allen

Age: 15

"The computer was invented to solve problems that didn't exist before."
hergipotter
Posts: 48
Joined: 12 Jan 2011, 18:40
Contact:

Re: Logic opposite?

Post by hergipotter »

I don't use NXT-G but there sure is a "NOT" Block, isn't it?
link to my youtube channel under my avatar!
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Logic opposite?

Post by mattallen37 »

You want a 1 to be 0, and a 0 to be 1? How about using x = 1 - n ?
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
h-g-t
Posts: 552
Joined: 07 Jan 2011, 08:59
Location: Albania

Re: Logic opposite?

Post by h-g-t »

In this sort of situation I normally use +1 as forward and -1 as reverse.

All you have to do is multiply by -1 to change the sign.
A sophistical rhetorician, inebriated with the exuberance of his own verbosity, and gifted with an egotistical imagination that can at all times command an interminable and inconsistent series of arguments to malign an opponent and to glorify himself.
legostormrobot
Posts: 19
Joined: 12 Jul 2012, 17:48

Re: Logic opposite?

Post by legostormrobot »

There were a couple my blocks on the lego website that when put together make an "opposite" block. So the logic to number converts logic (yes) to number (1) and then number to logic converts odd numbers to false and even numbers to true, so in this example, the input 1 would be made false and the input 0 would be made true.

The "not" block can work with a switch to say if true do this, if false do that.

If I converted logic to number, (l=logic) l -1 should work, then convert it back to logic.... if it counts -1 as true! Might work...
Noah Allen

Age: 15

"The computer was invented to solve problems that didn't exist before."
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 5 guests