Advertisement
Guest User

Untitled

a guest
Apr 29th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. const int buzzer = 8;
  2. // the setup function runs once when you press reset or power the board
  3. void setup() {
  4. // initialize digital pin LED_BUILTIN as an output.
  5. pinMode(LED_BUILTIN, OUTPUT);
  6. pinMode(buzzer,OUTPUT);
  7. }
  8.  
  9. // the loop function runs over and over again forever
  10. void loop() {
  11. char a[4];
  12. char b[3]={'0','4','0'};
  13. scanf("%c%c%c",&a[0],&a[1],&a[2]);
  14. for(int j=0;j<3;j++){
  15. if(a[j]>b[j]){
  16. for(int i=0;i<30;i++){
  17. digitalWrite(LED_BUILTIN, HIGH);
  18. tone(buzzer,1000);
  19. delay(100); // wait for a second
  20. digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
  21. tone(buzzer,500);
  22. delay(100);
  23. }
  24. noTone(buzzer);
  25. break;
  26. }
  27. else if(a[j]<b[j]) break;
  28. }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement