opgave 4 en speaker

This commit is contained in:
2016-02-02 15:57:02 +01:00
parent 2c1459b485
commit 88f86376dd
4 changed files with 141 additions and 91 deletions
+38 -2
View File
@@ -30,16 +30,39 @@ Version : DMK, Initial code
int main(void)
{
DDRD = 0b11111111; // All pins PORTD are set to output
DDRD = 0b00000000; //input
DDRC = 0b11111111; //output
//Alleen voor opgave 4
PORTC = 0x1;
while (1)
{
opgave1( );
//opgave1();
//opgave2();
//opgave3();
opgave4();
/*
if( (PIND) != 0 )
{
speaker( PIND );
}
*/
}
return 1;
}
void speaker(int i)
{
//PORTC moet hiervoor output zijn en PORTD input
PORTC = 0b01010101;
wait( i );
PORTC = 0b00000000;
wait( i );
}
void opgave1(void)
{
PORTD = 0b10000000;
@@ -48,3 +71,16 @@ void opgave1(void)
wait ( 500 );
}
void opgave4(void)
{
wait( 50 );
if (PORTC>= 0x80)
{
PORTC= 0x1;
}
else
{
PORTC = (PORTC<<1);
}
}