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 revisionPrevious revision
Next revision
Previous revision
lego_nxt_optical_sensor [2018/10/02 14:35] – [3, Materials and Software] phamquyenanhlego_nxt_optical_sensor [2018/10/02 15:10] (current) – [Code] phamquyenanh
Line 70: Line 70:
 | Lego NXT breadboard adapter   | https://www.generationrobots.com/en/401251-nxt-breadboard-adapter-dexter-industries.html | | Lego NXT breadboard adapter   | https://www.generationrobots.com/en/401251-nxt-breadboard-adapter-dexter-industries.html |
 | LEGO Mindstorms NXT / EV3 Connector Cables  | https://www.amazon.com/LEGO-Mindstorms-NXT-Connector-Cables/dp/B00G1L8J5A | | LEGO Mindstorms NXT / EV3 Connector Cables  | https://www.amazon.com/LEGO-Mindstorms-NXT-Connector-Cables/dp/B00G1L8J5A |
-==== Software and Sources ==== +
-  * Arduino ide +
-  * ROBOTC for LEGO Mindstorms+
 ===== 4, Interface A Sensor Mouse with Arduino  via PS/2 protocol ===== ===== 4, Interface A Sensor Mouse with Arduino  via PS/2 protocol =====
 ==== Connection ==== ==== Connection ====
Line 151: 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> 
Line 257: Line 282:
   - http://datasheetcafe.databank.netdna-cdn.com/wp-content/uploads/2015/11/SPCP168A.pdf   - http://datasheetcafe.databank.netdna-cdn.com/wp-content/uploads/2015/11/SPCP168A.pdf
 If you have any questions please contact for me via email [email protected]. If you have any questions please contact for me via email [email protected].
 +===== Download =====
 +{{:wiki:i2cnxtandarduino.rar|}}
  
  
  
  
lego_nxt_optical_sensor.1538516159.txt.gz · Last modified: 2018/10/02 14:35 by phamquyenanh