uuu000

SWITCH TENP

Oct 9th, 2021
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. /*
  2. * switch temp.c
  3. *
  4. * Created: 07.10.2021 15:19:00
  5. * Author : rockd
  6. */
  7.  
  8. /*
  9. * C Program to Blink an LED with ATmega32 Microcontroller
  10. *
  11. * Author: DILIP RAJA
  12. */
  13. #include <avr/io.h>
  14. #define F_CPU 1000000
  15. #include <util/delay.h>
  16.  
  17. #define time 80
  18. void pause (unsigned long a)
  19.  
  20. {
  21. unsigned long counter ;
  22. for(counter=a;counter>0;counter--)
  23. asm("nop");
  24. }
  25. int main(void)
  26. {
  27. uint8_t i=0;
  28. DDRB = 0b11111101;
  29. //DDRC = 0x0;
  30. PORTB|=(1<<PB1);
  31. while(1)
  32. {
  33.  
  34.  
  35.  
  36. //_delay_ms(20);
  37. pause (100L*time);
  38. switch(i)
  39. {
  40. case 0:
  41. PORTB|=(1<<PB0);
  42. break;
  43. pause (5L*time);
  44. case 1:
  45. PORTB|=(1<<PB0);
  46. pause (100L*time);
  47. //_delay_ms(500);
  48. PORTB&=~(1<<PB0);
  49. pause (100L*time);
  50. //_delay_ms(500);
  51. break;
  52. pause (5L*time);
  53. case 2:
  54. PORTB|=(1<<PB0);
  55. pause (20L*time);
  56. //_delay_ms(100);
  57. PORTB&=~(1<<PB0);
  58. pause (20L*time);
  59. //_delay_ms(100);
  60. break;
  61. pause (5L*time);
  62. case 3:
  63. PORTB|=(1<<PB0);
  64. pause (10L*time);
  65. //_delay_ms(50);
  66. PORTB&=~(1<<PB0);
  67. pause (10L*time);
  68. //_delay_ms(50);
  69. break;
  70. pause (5L*time);
  71. case 4:
  72. PORTB|=(1<<PB0);
  73. pause (5L*time);
  74. //_delay_ms(20);
  75. PORTB&=~(1<<PB0);
  76. pause (5L*time);
  77. //_delay_ms(20);
  78. break;
  79. pause (5L*time);
  80. case 5:
  81. PORTB|=(1<<PB0);
  82. pause (2L*time);
  83. //_delay_ms(1000);
  84. PORTB&=~(1<<PB0);
  85. pause (2L*time);
  86. //_delay_ms(1000);
  87. break;
  88. pause (5L*time);
  89. //default:
  90. //PORTD|=(1<<PB6);
  91. //break;
  92. }
  93. pause (1000L*time);
  94. //_delay_ms(400);
  95. }
  96. }
  97.  
  98.  
  99.  
  100.  
Advertisement
Add Comment
Please, Sign In to add comment