lego_nxt_optical_sensor
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
lego_nxt_optical_sensor [2018/10/02 14:17] – [5, Send data from an Arduino to LEGO NXT via I2C] phamquyenanh | lego_nxt_optical_sensor [2018/10/02 15:10] (current) – [Code] phamquyenanh | ||
---|---|---|---|
Line 19: | Line 19: | ||
{{ : | {{ : | ||
The SPCP168A datasheet : http:// | The SPCP168A datasheet : http:// | ||
- | ===== 2, PS/2 protocal | + | ===== 2, PS/2 protocol |
==== PS/2 connection ==== | ==== PS/2 connection ==== | ||
The PS/2 connection is the IBM standard protocol to communicate keyboard, PC mouse with your computer. This protocol has the responsibility to send the key scan codes that you press to the pc and get some response commands from it. This means that we are dealing with a bi-directional type of protocol as each device (pc/ | The PS/2 connection is the IBM standard protocol to communicate keyboard, PC mouse with your computer. This protocol has the responsibility to send the key scan codes that you press to the pc and get some response commands from it. This means that we are dealing with a bi-directional type of protocol as each device (pc/ | ||
Line 56: | Line 56: | ||
</ | </ | ||
| | ||
- | ===== 3, Materials | + | ===== 3, Materials |
==== Materials and Sources ==== | ==== Materials and Sources ==== | ||
Line 70: | Line 70: | ||
| Lego NXT breadboard adapter | | Lego NXT breadboard adapter | ||
| LEGO Mindstorms NXT / EV3 Connector Cables | | LEGO Mindstorms NXT / EV3 Connector Cables | ||
- | ==== Software and Sources ==== | + | |
- | * Arduino ide | + | |
- | * ROBOTC for LEGO Mindstorms | + | |
===== 4, Interface A Sensor Mouse with Arduino | ===== 4, Interface A Sensor Mouse with Arduino | ||
==== Connection ==== | ==== Connection ==== | ||
Line 151: | Line 149: | ||
// put a hold on the incoming data | // put a hold on the incoming data | ||
low(_clockPin); | low(_clockPin); | ||
+ | } | ||
+ | </ | ||
+ | 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; | ||
+ | { | ||
+ | Sum+=(int)DataWheel[count]; | ||
+ | } | ||
+ | if(Sum> | ||
+ | else if(Sum< | ||
+ | Sum=0; | ||
+ | } | ||
} | } | ||
</ | </ | ||
Line 247: | Line 272: | ||
} | } | ||
</ | </ | ||
- | ===== reference ===== | ||
- | If you have any questions please contact | + | **Video** |
+ | {{youtube> | ||
+ | ===== Reference ===== | ||
+ | - https:// | ||
+ | - http:// | ||
+ | - https:// | ||
+ | - http:// | ||
+ | - http:// | ||
+ | If you have any questions please contact | ||
+ | ===== Download ===== | ||
+ | {{: | ||
lego_nxt_optical_sensor.1538515069.txt.gz · Last modified: 2018/10/02 14:17 by phamquyenanh