This drive is working well with "LPD3806-600BM-G5-24G", and have Simple program, external pull-up resistance is required
注意:需要外置上拉电阻。
main.cpp@2:7d34758c3cc4, 2019-02-08 (annotated)
- Committer:
- Yifan_Du
- Date:
- Fri Feb 08 07:11:22 2019 +0000
- Revision:
- 2:7d34758c3cc4
- Parent:
- 1:4d205546ec69
Add instruction
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Yifan_Du | 1:4d205546ec69 | 1 | // Attention: External pull-up resistance is required |
Yifan_Du | 2:7d34758c3cc4 | 2 | /* |
Yifan_Du | 2:7d34758c3cc4 | 3 | Red Line -> 5V |
Yifan_Du | 2:7d34758c3cc4 | 4 | Black Line -> GND |
Yifan_Du | 2:7d34758c3cc4 | 5 | Green Line -> your STM32 pin |
Yifan_Du | 2:7d34758c3cc4 | 6 | White Line -> your STM32 pin |
Yifan_Du | 2:7d34758c3cc4 | 7 | */ |
Yifan_Du | 0:b2ffb830539c | 8 | #include "mbed.h" |
Yifan_Du | 0:b2ffb830539c | 9 | #include "Rotary_Encoder.h" |
Yifan_Du | 1:4d205546ec69 | 10 | // (White Line, Green Line) |
Yifan_Du | 0:b2ffb830539c | 11 | Rotary_Encoder Encoder(PA_0, PA_1); |
Yifan_Du | 0:b2ffb830539c | 12 | |
Yifan_Du | 0:b2ffb830539c | 13 | int main(void) |
Yifan_Du | 0:b2ffb830539c | 14 | { |
Yifan_Du | 0:b2ffb830539c | 15 | while(1) |
Yifan_Du | 0:b2ffb830539c | 16 | { |
Yifan_Du | 0:b2ffb830539c | 17 | printf("Direction: %s\r\n", Encoder.Calculate_Direction()); |
Yifan_Du | 0:b2ffb830539c | 18 | printf("\r\n"); |
Yifan_Du | 0:b2ffb830539c | 19 | |
Yifan_Du | 0:b2ffb830539c | 20 | wait(0.2); |
Yifan_Du | 0:b2ffb830539c | 21 | } |
Yifan_Du | 0:b2ffb830539c | 22 | } |