User Tools

Site Tools


lego_nxt_optical_sensor

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
lego_nxt_optical_sensor [2018/10/02 14:45]
phamquyenanh [Download]
lego_nxt_optical_sensor [2018/10/02 15:10]
phamquyenanh [Code]
Line 149: Line 149:
     // put a hold on the incoming data     // put a hold on the incoming data
     low(_clockPin);​     low(_clockPin);​
 +}
 +</​code> ​
 +Reading data from optical mouse sensor
 +<code c Read>
 +void readdd()
 +{
 +  requestData();​
 +  Dstatu = readByte(); // this byte for buttons
 +  Dx = readByte(); ​  
 +  Dy = readByte();
 +  if (_supportsIntelliMouseExtensions) {
 +        DataWheel[count] = readByte();
 +        count++;
 +        ​
 +    }
 +  X += (int)Dx;
 +  Y += (int)Dy;
 +  if(count==3)
 +  {
 +    for(count;​count>​=0;​count--)
 +    { 
 +      Sum+=(int)DataWheel[count];​
 +    }
 +    if(Sum>​0) W++;
 +    else if(Sum<​0) W--;
 +    Sum=0;​count=0;​
 +  }
 } }
 </​code> ​ </​code> ​
lego_nxt_optical_sensor.txt ยท Last modified: 2018/10/02 15:10 by phamquyenanh