Momentan habe ich leider keine keramikkondensatoren.
Code:
#include <avr/io.h>
#define F_CPU 1000000
#include <util/delay.h>
#include <stdint.h>
int main(void)
{
int time = 0;
int second = 0;
int time_e = 0;
int time_z = 0;
int tast = 0;
DDRB = 255;
DDRA = 225;
DDRD = 0;
PORTD = 255;
DDRC = 225;
while(1)
{
if (PIND == (PIND & 0b11101111))
{
if (tast == 0)
{
tast = 1;
PORTC = 0b00000001;
}
else
{
tast = 0;
PORTC = 0b00000000;
}
}
if (tast == 0)
{
second = 0;
}
if (PIND == (PIND & 0b10111111))// 5 ist taster links
{
time--;
}
if (PIND == (PIND & 0b11011111))// hier ist das problem
{
time++;
}
time_z =(time/10);
time_e = time - (time_z*10);
if (time_z == 6)
{
PORTA = 0b00111111;
}
if (time_z == 5)
{
PORTA = 0b00011111;
}
if (time_z == 4)
{
PORTA = 0b00001111;
}
if (time_z == 3)
{
PORTA = 0b00000111;
}
if (time_z == 2)
{
PORTA = 0b00000011;
}
if (time_z == 1)
{
PORTA = 0b00000001;
}
if (time_z == 0)
{
PORTA = 0b00000000;
}
if (time_e==9)
{
PORTA = PORTA + 0b01000000;
PORTB = 0b11111111;
}
else if (time_e==8)
{
PORTB = 0b11111111;
}
else if (time_e==7)
{
PORTB = 0b01111111;
}
else if (time_e==6)
{
PORTB = 0b00111111;
}
else if (time_e==5)
{
PORTB = 0b00011111;
}
else if (time_e==4)
{
PORTB = 0b00001111;
}
else if (time_e==3)
{
PORTB = 0b00000111;
}
else if (time_e==2)
{
PORTB = 0b00000011;
}
else if (time_e==1)
{
PORTB = 0b00000001;
}
else if (time_e==0)
{
PORTB = 0b00000000;
}
_delay_ms(200);
second ++;
if (second == 300)
{
time --;
second = 0;
}
}
}
Mein wunderschönes Programm.
Wie genau macht man da smit den fuse bits? Ich benutze AVR studio.
Lesezeichen