Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
I'm using an optical encoder to record the pulses of an optical disc.
Problem is it the encoder values does not add up. I think It's cause I'm passing it wrong.
#include "mbed.h" Serial pc(USBTX, USBRX); Serial ax500(p9,p10); InterruptIn trigger_A(p26); InterruptIn trigger_B(p25); Ticker calculate; int enc_A,enc_B=0; void tick_A(){ // This is not adding up enc_A++; } void tick_B(){ // This is not adding up enc_B++; } void calc(){ pc.printf("Enc_A=%i \t Enc_B=%i \r\n",enc_A,enc_B); // Values keep printing 0 for both EncA and EncB. } int main() { while(1) { calculate.attach(&calc, 1.0); ax500.printf("!a7F\r"); ax500.printf("!b7F\r"); wait(2); ax500.printf("!a00\r"); ax500.printf("!b00\r"); wait(2); ax500.printf("!A7F\r"); ax500.printf("!B7F\r"); wait(2); ax500.printf("!a00\r"); ax500.printf("!b00\r"); wait(2); } }