12.07.2015 Views

Programming Manual Elektor Proton Robot - ELEKTOR.se

Programming Manual Elektor Proton Robot - ELEKTOR.se

Programming Manual Elektor Proton Robot - ELEKTOR.se

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

__delay_ms(30); // When read to fast - value isstill 0while (ENC > 165) // wheels turn backwards -encoder counts back{ENC = I2C_RECEIVE_MESSAGE(0xB0,2); //always dummy read high byte fist - this buffers the 4 encregsENC = I2C_RECEIVE_MESSAGE(0xB0,5); // lowbyteLCD03_SET_CURSOR(43);char enc[20] = "ENCOD: ";LCD_WRITE_STRING(enc);LCD03_WRITE_BYTE(ENC);}}el<strong>se</strong> if (PORTB & 0b00100000) //black switch{I2C_SEND_MESSAGE(0xB0,16,32); //clear allencoder registersI2C_SEND_MESSAGE(0xB0,0,135); // Slow forwardI2C_SEND_MESSAGE(0xB0,1,135);ENC = 0;while (ENC < 90) // wheels turn forward -encoder increments{ENC = I2C_RECEIVE_MESSAGE(0xB0,2); //always dummy read high byte fist - this buffers the 4 encregsENC = I2C_RECEIVE_MESSAGE(0xB0,5); // lowbyteLCD03_SET_CURSOR(43);char enc[20] = "ENCOD: ";LCD_WRITE_STRING(enc);LCD03_WRITE_BYTE(ENC);}}el<strong>se</strong>{I2C_SEND_MESSAGE(0xB0,0,128); // stop wheelsI2C_SEND_MESSAGE(0xB0,1,128);}}}always dummy read high byte fist - this buffers the 4 encregsENC = I2C_RECEIVE_MESSAGE(0xB0,5); // lowbyteLCD03_SET_CURSOR(43);LCD03_WRITE_STRING("ENCOD: ");LCD03_WRITE_BYTE(ENC);}}el<strong>se</strong> if (PIND & 0b00001000) //black switch{I2C_SEND_MESSAGE(0xB0,16,32); //clear allencoder registersI2C_SEND_MESSAGE(0xB0,0,135); // Slow forwardI2C_SEND_MESSAGE(0xB0,1,135);ENC = 0;while (ENC < 90) // wheels turn forward -encoder increments{ENC = I2C_RECEIVE_MESSAGE(0xB0,2); //always dummy read high byte fist - this buffers the 4 encregsENC = I2C_RECEIVE_MESSAGE(0xB0,5); // lowbyteLCD03_SET_CURSOR(43);LCD03_WRITE_STRING("ENCOD: ");LCD03_WRITE_BYTE(ENC);}}}el<strong>se</strong>{I2C_SEND_MESSAGE(0xB0,0,128); // stop wheelsI2C_SEND_MESSAGE(0xB0,1,128);}}Bart Huyskens <strong>Manual</strong> <strong>Elektor</strong> <strong>Proton</strong> V1.0 3 April 2011 72

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!