Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Simple countdown*/
- byte potPin = A0;
- byte photoPin = A1;
- int speakerPin = 11;
- byte LED=13;
- void setup() {
- DDRD=B11111110;
- pinMode(speakerPin, OUTPUT);
- pinMode(LED,OUTPUT);
- }
- void loop() {
- if (analogRead(potPin)>analogRead(photoPin)) {
- for (int i=0; i<1000; i++) {
- digitalWrite(speakerPin, HIGH);
- delayMicroseconds(250);
- digitalWrite(speakerPin, LOW);
- delayMicroseconds(250);
- }
- delay (500);
- PORTD=B11111100;//0 on
- delay(500);
- digitalWrite(LED, HIGH);
- delay(500);
- PORTD=B00000000;//0 off
- delay(500);
- digitalWrite(LED,LOW);
- delay(500);
- PORTD=B01100000;//1 on
- delay(500);
- digitalWrite(LED,HIGH);
- delay(500);
- PORTD=B00000000;//1 off
- delay(500);
- digitalWrite(LED,LOW);
- delay(500);
- PORTD=B11011010;//2 on
- delay(500);
- PORTD=B00000000;//2 off
- delay(500);
- PORTD=B11110010;//3 on
- delay(500);
- PORTD=B00000000;//3 off
- delay(500);
- PORTD=B01100110;//4 on
- delay(500);
- PORTD=B00000000;//4 off
- delay(500);
- PORTD=B10110110;//5 on
- delay(500);
- PORTD=B00000000;//5 off
- delay(500);
- PORTD=B10111110;//6 on
- delay(500);
- PORTD=B00000000;//6 off
- delay(500);
- PORTD=B11100000;//7 on
- delay(500);
- PORTD=B00000000;//7 off
- delay(500);
- PORTD=B11111110;//8 on
- delay(500);
- PORTD=B00000000;//8 off
- delay(500);
- PORTD=B11100110;//9 on
- delay(500);
- PORTD=B00000000;//9 off
- delay(500);
- }else if {
- PORTD=B00000000;
- } //End If / Else
- } //End Loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement