This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| de:robot:intro [2009/04/06 16:35] – nierhoff | de:robot:intro [2020/07/20 12:00] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Distance Lab Roboter ====== | ||
| + | Der Roboter kann auf verschiedene Weisen bestückt werden: | ||
| + | * Manipulator (Abb. 1) | ||
| + | * Einfacher Radar (Abb. 2) | ||
| + | * Kamera | ||
| + | |||
| + | {{http:// | ||
| + | |||
| + | Abb. 1 Roboter mit Manipulator | ||
| + | |||
| + | {{http:// | ||
| + | |||
| + | Abb. 2 Roboter mit Infrarot Radar | ||
| + | |||
| + | |||
| + | ===== Grundlegende Navigation ===== | ||
| + | |||
| + | |||
| + | <code c> | ||
| + | #define F_CPU 14745600UL //CPU Frequenz (beeinflusst delay Funktion) | ||
| + | #include < | ||
| + | #include < | ||
| + | |||
| + | |||
| + | int init(){ | ||
| + | DDRD = 0xFF;// set port direction (output) | ||
| + | PORTD = 0x00;// initialize port | ||
| + | |||
| + | //Pamperi lülitid | ||
| + | DDRC = 0x00;// set port direction (input) | ||
| + | PORTC = 0x00;// initialize port | ||
| + | |||
| + | DDRA = 0x00;// set port direction (input) | ||
| + | PORTA = 0x00;// initialize port | ||
| + | |||
| + | DDRB = 0xFF;// set port direction (output) | ||
| + | PORTB = 0x00;// initialize port | ||
| + | |||
| + | DDRG = 0xFF; // set port direction (output) | ||
| + | PORTG = 0x00;// initialize port - pins-s low | ||
| + | return 0; | ||
| + | } | ||
| + | |||
| + | int edasi(){ | ||
| + | PORTD=0x02; | ||
| + | PORTB=0x80; | ||
| + | return 0; | ||
| + | } | ||
| + | |||
| + | int tagasi(){ | ||
| + | PORTD=0x01; | ||
| + | PORTB=0x10; | ||
| + | return 0; | ||
| + | } | ||
| + | |||
| + | int stop(){ | ||
| + | PORTD=0x00; | ||
| + | PORTB=0x00; | ||
| + | return 0; | ||
| + | } | ||
| + | |||
| + | int poore_vasak(){ | ||
| + | PORTD=0x01; | ||
| + | PORTB=0x80; | ||
| + | return 0; | ||
| + | } | ||
| + | |||
| + | int poore_parem(){ | ||
| + | PORTD=0x02; | ||
| + | PORTB=0x10; | ||
| + | return 0; | ||
| + | } | ||
| + | |||
| + | int main (void){ | ||
| + | |||
| + | init(); | ||
| + | |||
| + | while(1){ | ||
| + | |||
| + | edasi(); | ||
| + | |||
| + | if (bit_is_set(PINA, | ||
| + | tagasi(); | ||
| + | _delay_ms(500); | ||
| + | poore_parem(); | ||
| + | _delay_ms(1000); | ||
| + | } | ||
| + | |||
| + | if (bit_is_set(PINA, | ||
| + | tagasi(); | ||
| + | _delay_ms(500); | ||
| + | poore_vasak(); | ||
| + | _delay_ms(1000); | ||
| + | } | ||
| + | |||
| + | if (bit_is_set(PINC, | ||
| + | stop(); | ||
| + | _delay_ms(1000); | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </ | ||