v1.1

Dependencies:   mbed QEI

Committer:
pokpongc
Date:
Sun May 05 10:19:43 2019 +0000
Revision:
1:8e3af9643155
Parent:
0:ef2ee7458c37
Child:
2:eb82f5cb5098
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pokpongc 0:ef2ee7458c37 1 #include "mbed.h"
pokpongc 0:ef2ee7458c37 2 #include "QEI.h"
pokpongc 0:ef2ee7458c37 3
pokpongc 0:ef2ee7458c37 4 Serial pc(USBTX, USBRX);
pokpongc 0:ef2ee7458c37 5
pokpongc 0:ef2ee7458c37 6 QEI temp_dial(D11, D12, A1, 50, QEI::X4_ENCODING);
pokpongc 0:ef2ee7458c37 7 BusIn joy_bus{D3, D4, D5, D6};
pokpongc 0:ef2ee7458c37 8 BusIn button_bus{D7, D9};
pokpongc 1:8e3af9643155 9 DigitalIn a(D7),b(D9),c(D3),d(D4),e(D5),f(D6); //Dummy pin for pulling
pokpongc 0:ef2ee7458c37 10
pokpongc 0:ef2ee7458c37 11
pokpongc 1:8e3af9643155 12 void init_();
pokpongc 1:8e3af9643155 13
pokpongc 0:ef2ee7458c37 14 int main() {
pokpongc 0:ef2ee7458c37 15 pc.baud(115200);
pokpongc 0:ef2ee7458c37 16 long pulse = 0;
pokpongc 1:8e3af9643155 17 init_();
pokpongc 0:ef2ee7458c37 18 while(1){
pokpongc 0:ef2ee7458c37 19 pulse = temp_dial.getPulses()/2;
pokpongc 0:ef2ee7458c37 20 pc.printf("%d \t%d\n",joy_bus.read(), button_bus.read());
pokpongc 0:ef2ee7458c37 21
pokpongc 0:ef2ee7458c37 22
pokpongc 0:ef2ee7458c37 23 }
pokpongc 0:ef2ee7458c37 24 }
pokpongc 0:ef2ee7458c37 25
pokpongc 1:8e3af9643155 26
pokpongc 1:8e3af9643155 27 void init_(){
pokpongc 1:8e3af9643155 28 a.mode(PullDown);
pokpongc 1:8e3af9643155 29 b.mode(PullDown);
pokpongc 1:8e3af9643155 30 c.mode(PullDown);
pokpongc 1:8e3af9643155 31 d.mode(PullDown);
pokpongc 1:8e3af9643155 32 e.mode(PullDown);
pokpongc 1:8e3af9643155 33 f.mode(PullDown);
pokpongc 1:8e3af9643155 34 }