Professional Documents
Culture Documents
Simulation Traffict Light
Simulation Traffict Light
b. Buttom Layout
3. Program
a. Time Table
b. Table Konversi
c. Coding AVR
1. #include <mega16.h>
2. #include <delay.h>
3.
4. void main(void)
5. {
6. PORTB=0x00;
7. PORTD=0x00;
8. DDRB=0xFF;
9. DDRD=0xFF;
10.
11.
12. while (1)
13. {
14. PORTB=0x4C;
15. PORTD=0x08;
16. delay_ms(3000);
17. PORTB=0x54;
18. PORTD=0x08;
19. delay_ms(1000);
20. PORTB=0x64;
21. PORTD=0x08;
22. delay_ms(1000);
23. PORTB=0x61;
24. PORTD=0x08;
25. delay_ms(3000);
26. PORTB=0x62;
27. PORTD=0x08;
28. delay_ms(1000);
29. PORTB=0x64;
30. PORTD=0x08;
31. delay_ms(1000);
32. PORTB=0x24;
33. PORTD=0x09;
34. delay_ms(3000);
35. PORTB=0xA4;
36. PORTD=0x08;
37. delay_ms(1000);
38. PORTB=0x64;
39. PORTD=0x08;
40. delay_ms(1000);
41. PORTB=0x64;
42. PORTD=0x02;
43. delay_ms(3000);
44. PORTB=0x64;
45. PORTD=0x04;
46. delay_ms(1000);
47. PORTB=0x64;
48. PORTD=0x08;
49. delay_ms(1000);
50. };
51.
52. }