Code for LED


SUBMITTED BY: Guest

DATE: May 19, 2013, 11:58 a.m.

FORMAT: Text only

SIZE: 780 Bytes

HITS: 911

  1. void setup()
  2. {
  3. // Starting registering states
  4. //Pin state must be declared using PORTx Command
  5. //First bits (00) of PORTB correspond to nothing
  6. PORTB = B00101010;
  7. //WARNING: last bits of PORTD (...10) correspond to RX and TX pins, do not change them!
  8. PORTD= B10000010;
  9. }
  10. void loop()
  11. {
  12. //Light up pins 13, 11 , 9 , 7
  13. DDRB = B00101010;
  14. DDRD = B10000010;
  15. delay(1000);
  16. //Lights off
  17. PORTB = B00000000;
  18. PORTD = B00000010;
  19. DDRB = B00000000;
  20. DDRD = B00000010;
  21. // Light up pins 12, 10, 8, 6
  22. PORTB = B00010101;
  23. PORTD = B01000010;
  24. DDRB = B00010101;
  25. DDRD = B01000010;
  26. delay(1000);
  27. //sets 13, 11, 9, 7 pins back to outputs to be looped again
  28. PORTB = B00101010;
  29. PORTD= B10000010;
  30. }

comments powered by Disqus