Skip to content
Snippets Groups Projects
Commit bf54fa55 authored by Peter Gerwinski's avatar Peter Gerwinski
Browse files

Beispiel-Programme und Tafelbild 3.12.2018

parent 4d1b4525
No related branches found
No related tags found
No related merge requests found
Showing with 380 additions and 0 deletions
#include <avr/io.h>
int main (void)
{
DDRD = 0x40; /* binär: 0100 0000 */
PORTD = 0x40; /* binär: 0100 0000 */
while (1);
return 0;
}
#include <avr/io.h>
int main (void)
{
DDRD = 0x7f; /* binär: 0111 1111 */
PORTD = 0x40; /* binär: 0100 0000 */
while (1);
return 0;
}
#include <avr/io.h>
#define F_CPU 16000000l
#include <util/delay.h>
int main (void)
{
DDRD = 0x01;
PORTD |= 0x01;
while (1)
{
_delay_ms (500);
PORTD &= ~0x01;
_delay_ms (500);
PORTD |= 0x01;
}
return 0;
}
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdint.h>
#define F_CPU 16000000l
#include <util/delay.h>
volatile uint8_t key_pressed = 0;
ISR (INT0_vect) /* PD2 */
{
key_pressed = 1;
}
int main (void)
{
cli ();
EICRA = 1 << ISC00 | 1 << ISC01; /* INT0: steigende Flanke */
EIMSK = 1 << INT0; /* INT0 einschalten */
sei ();
DDRD = 0xfb; /* binär: 1111 1011 */
PORTD = 0x40; /* binär: 0100 0000 */
while (1)
{
while (!key_pressed)
; /* just wait */
PORTD ^= 0x40;
key_pressed = 0;
}
return 0;
}
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdint.h>
#define F_CPU 16000000l
#include <util/delay.h>
volatile uint8_t key_pressed = 0;
ISR (INT0_vect) /* PD2 */
{
key_pressed = 1;
}
int main (void)
{
cli ();
EICRA = 1 << ISC00 | 1 << ISC01; /* INT0: steigende Flanke */
EIMSK = 1 << INT0; /* INT0 einschalten */
sei ();
DDRD = 0xfb; /* binär: 1111 1011 */
PORTD = 0x40; /* binär: 0100 0000 */
while (1)
{
while (!key_pressed)
; /* just wait */
_delay_ms (1);
PORTD ^= 0x40;
key_pressed = 0;
}
return 0;
}
#include <avr/io.h>
#define F_CPU 16000000l
#include <util/delay.h>
int main (void)
{
DDRD = 0x02;
PORTD = 0x02;
while (1)
{
_delay_ms (250);
PORTD ^= 0x02;
}
return 0;
}
#include <avr/io.h>
#define F_CPU 16000000
#include <util/delay.h>
int main (void)
{
DDRD = 0x01;
PORTD = 0x01;
while (1)
{
while ((PIND & 0x02) == 0)
; /* just wait */
PORTD ^= 0x01;
}
return 0;
}
#include <avr/io.h>
#define F_CPU 16000000
#include <util/delay.h>
int main (void)
{
DDRD = 0x11;
PORTD = 0x11;
while (1)
{
while ((PIND & 0x02) == 0)
; /* just wait */
_delay_ms (100);
PORTD ^= 0x01;
}
return 0;
}
#include <avr/io.h>
#define F_CPU 16000000
#include <util/delay.h>
int main (void)
{
DDRD = 0x01;
PORTD = 0x01;
while (1)
{
while ((PIND & 0x02) == 0)
; /* just wait */
PORTD ^= 0x01;
_delay_ms (200);
}
return 0;
}
#include <avr/io.h>
#define F_CPU 16000000
#include <util/delay.h>
int main (void)
{
DDRD = 0x01; /* 00000001 */
PORTD = 0x03; /* 00000011 */
while (1)
{
while ((PIND & 0x02) == 0)
; /* just wait */
PORTD ^= 0x01;
_delay_ms (200);
}
return 0;
}
#include <avr/io.h>
#define F_CPU 16000000
#include <util/delay.h>
int main (void)
{
DDRD = 0x01; /* 00000001 */
PORTD = 0x03; /* 00000011 */
while (1)
; /* just wait */
return 0;
}
#include <avr/io.h>
#define F_CPU 16000000
#include <util/delay.h>
int main (void)
{
DDRD = 0x01; /* 00000001 */
PORTD = 0x03; /* 00000011 */
while (1)
{
_delay_ms (500);
PORTD ^= 0x02;
}
return 0;
}
#include <avr/io.h>
#include <avr/interrupt.h>
ISR (TIMER0_COMPB_vect)
{
PORTD ^= 0x40;
}
int main (void)
{
cli ();
TCCR0B = (1 << CS01) | (1 << CS00); /* Takt durch 64 dividieren */
TIMSK0 = 1 << OCIE0B; /* Interrupt einschalten */
sei ();
DDRD = 0xfd; /* binär: 1111 1101 */
PORTD = 0x40; /* binär: 0100 0000 */
while (1);
return 0;
}
#include <avr/io.h>
#include <avr/interrupt.h>
ISR (TIMER0_COMPB_vect)
{
PORTD ^= 0x40;
}
int main (void)
{
DDRD = 0xfd; /* binär: 1111 1101 */
PORTD = 0x40; /* binär: 0100 0000 */
while (1);
return 0;
}
#include <avr/io.h>
#include <avr/interrupt.h>
ISR (TIMER0_COMPB_vect)
{
PORTD ^= 0x40;
}
int main (void)
{
DDRD = 0xfd; /* binär: 1111 1101 */
PORTD = 0x00; /* binär: 0000 0000 */
while (1);
return 0;
}
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdint.h>
ISR (TIMER0_COMPB_vect)
{
static uint8_t counter = 0;
if (counter++ == 0)
PORTD ^= 0x40;
}
int main (void)
{
cli ();
TCCR0B = (1 << CS01) | (1 << CS00); /* Takt durch 64 dividieren */
TIMSK0 = 1 << OCIE0B; /* Interrupt einschalten */
sei ();
DDRD = 0xfd; /* binär: 1111 1101 */
PORTD = 0x40; /* binär: 0100 0000 */
while (1);
return 0;
}
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdint.h>
ISR (TIMER0_COMPB_vect)
{
static uint8_t counter = 0;
if (counter++ == 0)
PORTD ^= 0x40;
}
int main (void)
{
cli ();
TCCR0B = (1 << CS01) | (1 << CS00); /* Takt durch 64 dividieren */
TIMSK0 = 1 << OCIE0B; /* Interrupt einschalten */
sei ();
DDRD = 0xfd; /* binär: 1111 1101 */
PORTD = 0x40; /* binär: 0100 0000 */
cli ();
while (1);
return 0;
}
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdint.h>
ISR (INT0_vect) /* PD2 */
{
PORTD ^= 0x40;
}
int main (void)
{
cli ();
EICRA = 1 << ISC00 | 1 << ISC01; /* INT0: steigende Flanke */
EIMSK = 1 << INT0; /* INT0 einschalten */
sei ();
DDRD = 0xfb; /* binär: 1111 1011 */
PORTD = 0x40; /* binär: 0100 0000 */
while (1);
return 0;
}
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdint.h>
ISR (INT0_vect) /* PD2 */
{
PORTD ^= 0x40;
}
int main (void)
{
cli ();
EICRA = 1 << ISC00 | 1 << ISC01; /* INT0: steigende Flanke */
EIMSK = 1 << INT0; /* INT0 einschalten */
sei ();
DDRD = 0xff; /* binär: 1111 1111 */
PORTD = 0x40; /* binär: 0100 0000 */
while (1);
return 0;
}
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdint.h>
#define F_CPU 16000000l
#include <util/delay.h>
uint8_t key_pressed = 0;
ISR (INT0_vect) /* PD2 */
{
key_pressed = 1;
}
int main (void)
{
cli ();
EICRA = 1 << ISC00 | 1 << ISC01; /* INT0: steigende Flanke */
EIMSK = 1 << INT0; /* INT0 einschalten */
sei ();
DDRD = 0xfb; /* binär: 1111 1011 */
PORTD = 0x40; /* binär: 0100 0000 */
while (1)
{
while (!key_pressed)
; /* just wait */
PORTD ^= 0x40;
key_pressed = 0;
}
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment