Advertisement
Guest User

Untitled

a guest
Nov 25th, 2015
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. int main(void)
  2. {
  3. // DDRC = 0xFF; //Nakes PORTC as Output
  4. DDRC = 0b11111000; // set PC0,PC1,PC2 to input
  5. PORTC = 0b00000111; // set PC0,PC1,PC2 to high
  6. while(1) //infinite loop
  7. {
  8. if (bit_is_clear(PINC,2)) //if button on PC2 is pressed
  9. {
  10. while(bit_is_set(PINC,1))
  11. {
  12. PORTC |= _BV(PC5); //turn on
  13. PORTC |= _BV(PC4); //turn on
  14. _delay_ms(250); //0.5 second delay
  15. PORTC &= ~_BV(PC4); //turn off
  16. _delay_ms(250); //0.5 second delay
  17. PORTC |= _BV(PC4); //turn on
  18. _delay_ms(250); //0.5 second delay
  19. PORTC &= ~_BV(PC4); //turn off
  20. _delay_ms(250); //0.5 second delay
  21. PORTC |= _BV(PC4); //turn on
  22. _delay_ms(250); //0.5 second delay
  23. PORTC &= ~_BV(PC4); //turn off
  24. _delay_ms(250); //0.5 second delay
  25. PORTC |= _BV(PC4); //turn on
  26. _delay_ms(250); //0.5 second delay
  27. PORTC &= ~_BV(PC4); //turn off
  28. _delay_ms(250); //0.5 second delay
  29. PORTC |= _BV(PC4); //turn on
  30. _delay_ms(250); //0.5 second delay
  31. PORTC &= ~_BV(PC4); //turn off
  32. PORTC |= _BV(PC3); //turn on
  33. }
  34. }
  35. PORTC &= ~_BV(PC3); //turn off
  36. PORTC &= ~_BV(PC4); //turn off
  37. PORTC &= ~_BV(PC5); //turn off
  38. // num = random(4);
  39. _delay_ms(10); //0.5 second delay
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement