Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2015
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.57 KB | None | 0 0
  1. /*Simple countdown*/
  2.  
  3.  byte potPin = A0;
  4.  byte photoPin = A1;
  5.  int speakerPin = 11;
  6.  byte LED=13;
  7.  
  8.  void setup() {
  9.  
  10.     DDRD=B11111110;
  11.     pinMode(speakerPin, OUTPUT);
  12.     pinMode(LED,OUTPUT);
  13.  
  14.  }
  15.  
  16.  
  17.  
  18. void loop() {
  19.  
  20.     if (analogRead(potPin)>analogRead(photoPin)) {
  21.  
  22.         for (int i=0; i<1000; i++) {
  23.  
  24.           digitalWrite(speakerPin, HIGH);
  25.           delayMicroseconds(250);
  26.           digitalWrite(speakerPin, LOW);
  27.           delayMicroseconds(250);
  28.  
  29.         }
  30.  
  31.         delay (500);
  32.  
  33.    
  34.         PORTD=B11111100;//0 on
  35.         delay(500);
  36.         digitalWrite(LED, HIGH);
  37.         delay(500);
  38.  
  39.         PORTD=B00000000;//0 off
  40.         delay(500);
  41.         digitalWrite(LED,LOW);
  42.         delay(500);
  43.  
  44.         PORTD=B01100000;//1 on
  45.         delay(500);
  46.         digitalWrite(LED,HIGH);
  47.         delay(500);
  48.  
  49.         PORTD=B00000000;//1 off
  50.         delay(500);
  51.         digitalWrite(LED,LOW);
  52.         delay(500);
  53.  
  54.         PORTD=B11011010;//2 on
  55.         delay(500);
  56.  
  57.         PORTD=B00000000;//2 off
  58.         delay(500);
  59.  
  60.         PORTD=B11110010;//3 on
  61.         delay(500);
  62.  
  63.         PORTD=B00000000;//3 off
  64.         delay(500);
  65.  
  66.         PORTD=B01100110;//4 on
  67.         delay(500);
  68.         PORTD=B00000000;//4 off
  69.         delay(500);
  70.  
  71.         PORTD=B10110110;//5 on
  72.         delay(500);
  73.         PORTD=B00000000;//5 off
  74.         delay(500);
  75.  
  76.         PORTD=B10111110;//6 on
  77.         delay(500);
  78.         PORTD=B00000000;//6 off
  79.         delay(500);
  80.  
  81.         PORTD=B11100000;//7 on
  82.         delay(500);
  83.         PORTD=B00000000;//7 off
  84.         delay(500);
  85.  
  86.         PORTD=B11111110;//8 on
  87.         delay(500);
  88.         PORTD=B00000000;//8 off
  89.         delay(500);
  90.  
  91.         PORTD=B11100110;//9 on
  92.         delay(500);
  93.         PORTD=B00000000;//9 off
  94.         delay(500);
  95.  
  96.     }else if {
  97.  
  98.         PORTD=B00000000;
  99.  
  100.  
  101.     }   //End If / Else
  102.  
  103.  
  104.  
  105. } //End Loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement