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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The line <strong>se</strong>nsor module with 3 IR line <strong>se</strong>nsorsThis demo program demonstrated a basic line follow algorithm. The state of the 3 <strong>se</strong>nsors is visuali<strong>se</strong>d onthe LCD.PIC16F887Demoprogram Flowcode PIC V4PROTDEM_FCPIC_LINE.fcfDemoprogram Hitech C lite for PIC#include ATMEGA32Demoprogram Flowcode AVR V4PROTDEM_FCAVR_LINE.fcf_avrDemoprogram WinAVR C for AVR#include #include "PIC_PROTON_LIB.h"#define _XTAL_FREQ 19660800__CONFIG(0x2ff2); // <strong>se</strong>t HS Xtal etc__CONFIG(0x3fff);void main(){// init AD & Option regANSEL = 0;ANSELH = 0;OPTION = 0xC0;// end of init__delay_ms(250);__delay_ms(250); //wait for stable power supplyI2C_INIT(); // initialize I2C - LCD03 is a I2C LCDvolatile unsigned char LF_L, LF_R, LF_C, LFT_WHEEL,RGT_WHEEL;TRISB |=0b00000111; //B0,B1,B2 = Line <strong>se</strong>nsorsI2C_SEND_MESSAGE(0xB0,16,50); // Disable 2 <strong>se</strong>ctimeout in command regLCD03_CLEAR_SCREEN();LCD03_SET_CURSOR(21);char enc[20] = "WHEEL R C L WHEEL ";LCD_WRITE_STRING(enc);while (1){LF_L = ((PORTB & 0b00000001)); //B0LF_C = ((PORTB & 0b00000010)>>1); //B1LF_R = ((PORTB & 0b00000100)>>2); //B2LCD03_SET_CURSOR(41);char enc[20] = ".................. ";LCD_WRITE_STRING(enc);LCD03_SET_CURSOR(41);LCD03_WRITE_BYTE(RGT_WHEEL);LCD03_SET_CURSOR(45);LCD03_WRITE_BYTE(LF_R);LCD03_SET_CURSOR(48);LCD03_WRITE_BYTE(LF_C);LCD03_SET_CURSOR(51);LCD03_WRITE_BYTE(LF_L);#define F_CPU 19660800UL#include #include "AVR_PROTON_LIB.h"#include "AVR_PROTON_LIB.c"int main ( void ){_delay_ms(250);_delay_ms(250); //wait for stable power supplyI2C_INIT(); // initialize I2C - LCD03 is a I2C LCDvolatile unsigned char LF_L, LF_R, LF_C, LFT_WHEEL,RGT_WHEEL;I2C_SEND_MESSAGE(0xB0,16,50); // Disable 2 <strong>se</strong>ctimeout in command regLCD03_CLEAR_SCREEN();LCD03_SET_CURSOR(21);LCD03_WRITE_STRING("WHEEL R C L WHEEL");while (1){LF_L = ((PIND & 0b00010000)>>4); //D4LF_C = ((PIND & 0b00100000)>>5); //D5LF_R = ((PIND & 0b01000000)>>6); //D6LCD03_SET_CURSOR(41);LCD03_WRITE_STRING("LCD03_SET_CURSOR(41);LCD03_WRITE_BYTE(RGT_WHEEL);LCD03_SET_CURSOR(45);LCD03_WRITE_BYTE(LF_R);LCD03_SET_CURSOR(48);LCD03_WRITE_BYTE(LF_C);LCD03_SET_CURSOR(51);LCD03_WRITE_BYTE(LF_L);LCD03_SET_CURSOR(58);LCD03_WRITE_BYTE(LFT_WHEEL);"); //line 2 clearBart Huyskens <strong>Manual</strong> <strong>Elektor</strong> <strong>Proton</strong> V1.0 3 April 2011 81

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

Saved successfully!

Ooh no, something went wrong!