Page 1 of 1

NXT-G:Controlling motor duration with light sensor variables

Posted: 24 Jul 2013, 05:47
by simonauv
I'm trying to do a basic linefollow program which I can do without using variables easily enough but I thought I'd try and be a little more creative and put a calibration routine in, based loosely on the nxtprograms.com smoothfollow program calibration routine. As such I have four variables; White, Black, Grey, and Light. Light is a dynamic variable that is frequently rewritten from the light intensity value from a single light sensor. White and Black are measured by scanning to the left (and back again) whilst values are continually fed back so that the max. is set as White and the min. is set as Black. Grey is just (Black + White)/2. This, and the turn on green routine I've made, work but the line follow part based on the light sensors data and the variables don't work.

What I want to do is use these variables to control the duration of a motor block. I want it to move either left or right until it is either greater or less that Grey but nothing I've tried works. So far I've been doing things like this:

Image

and

Image

This does not work and I can't see why... how can I make this work?

TIA,

Simon

Re: NXT-G:Controlling motor duration with light sensor variables

Posted: 03 Aug 2013, 15:35
by simonauv
closed... we made it work on our own.