Ampel Aufgabe 2

 

/*Prototyp 1ms

*/

 

#include <stdio.h>

#include <reg517.h>

 

void wait1ms(unsigned int time);   //Prototyp Wartezeit

 

void main()                             //Anfang Hauptprogramm

{

            while(1)

            {

                        P4=0x24;

                        wait1ms(3000);

                        P4=0x34;

                        wait1ms(1000);

                        P4=0x0C;

                        wait1ms(3000);

                        P4=0x14;

                        wait1ms(1000);

                        P4=0x24;

                        wait1ms(3000);

                        P4=0x26;

                        wait1ms(1000);

                        P4=0x21;

                        wait1ms(3000);

                        P4=0x22;

                        wait1ms(1000);

            }

}

 

void wait1ms(unsigned int time)       //Funktion Wartezeit

{

            int k,i;

            for(k=0;k<time;k++)           //Schleife Anzahl ms

            {

                        for(i=0;i<480;i++);   //Schleife läuft 1ms

            }

}

 

Ampel Aufgabe 3

 

/*Prototyp 1ms

            Ampel Aufgabe 3 

*/

 

#include <stdio.h>

#include <reg517.h>

 

void wait1ms(unsigned int time);         //Prototyp Wartezeit

 

void main()                                        //Anfang Hauptprogramm

{

            while(1)

            {

                        P4=0xA4;                      //Alle Ampeln rot

                        wait1ms(5000);               

                        P4=0xB4;                      //Ampel_1 rot/gelb

                        wait1ms(1000);

                        P4=0x8C;                      //Ampel_1 grün

                        wait1ms(5000);

                        P4=0x94;                      //Ampel_1 gelb

                        wait1ms(1500);

                        P4=0xA4;                      //Alle Ampeln rot

                        wait1ms(3000);

                        P4=0x64;                      //Fussgänger grün

                        wait1ms(2000);

                        P4=0x66;                      //Fussgänger grün Ampel_2 rot/gelb

                        wait1ms(1000);

                        P4=0x61;                      //Fussgänger grün Ampel_2 grün

                        wait1ms(4000);

                        P4=0xA1;                        //Fussgänger rot Ampel_2 grün

                        wait1ms(1000);

                        P4=0xA2;                      //Fussgänger rot Ampel_2 gelb

                        wait1ms(1500);

            }

}

 

void wait1ms(unsigned int time)           //Funktion Wartezeit

{

            int k,i;

            for(k=0;k<time;k++)                   //Schleife Anzahl ms

            {

                        for(i=0;i<480;i++);           //Schleife läuft 1ms

            }

}