Advertisement
Guest User

Untitled

a guest
Dec 6th, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. Dharini Kapoor
  2.  
  3. 4.3 Experiment
  4.  
  5. December 6th, 2020
  6.  
  7. */
  8.  
  9.  
  10. void setup() {
  11. pinMode(13, OUTPUT);
  12. pinMode(12, OUTPUT);
  13. pinMode(6, OUTPUT);
  14. pinMode(8, INPUT);
  15. pinMode(2, OUTPUT);
  16. pinMode(4, OUTPUT);
  17. pinMode(3, OUTPUT);
  18.  
  19. }
  20. void loop() {
  21. if (digitalRead(8) == HIGH) {
  22. digitalWrite(13, HIGH);
  23. digitalWrite(4, HIGH);
  24. digitalWrite(2, HIGH);
  25. delay(1000);// delay for one second
  26. digitalWrite(12, HIGH);
  27. delay(330);// delay for 330 mili seconds
  28. // fade in from min to max in increments of 5 points:
  29. for (int fadeValue = 0 ; fadeValue <= 255; fadeValue += 5) {
  30. // sets the value (range from 0 to 255):
  31. analogWrite(6, fadeValue);
  32. // wait for 30 milliseconds to see the dimming effect
  33. delay(30);
  34.  
  35. }
  36. // fade out from max to min in increments of 5 points:
  37. for (int fadeValue = 255 ; fadeValue >= 0; fadeValue -= 5) {
  38. // sets the value (range from 0 to 255):
  39. analogWrite(6, fadeValue);
  40. // wait for 30 milliseconds to see the dimming effect
  41. delay(30);
  42. }
  43.  
  44. // fade in from min to max in increments of 5 points:
  45. for (int fadeValue = 0 ; fadeValue <= 255; fadeValue += 5) {
  46. // sets the value (range from 0 to 255):
  47. analogWrite(3, fadeValue);
  48. // wait for 30 milliseconds to see the dimming effect
  49. delay(30);
  50.  
  51. }
  52. // fade out from max to min in increments of 5 points:
  53. for (int fadeValue = 255 ; fadeValue >= 0; fadeValue -= 5) {
  54. // sets the value (range from 0 to 255):
  55. analogWrite(3, fadeValue);
  56. // wait for 30 milliseconds to see the dimming effect
  57. delay(30);
  58. }
  59.  
  60. } else {
  61. digitalWrite(13, LOW);
  62. delay(1000); // delay for one second
  63. digitalWrite(12, LOW); // turn of pin 12
  64. delay(4000); // delay for 4 second
  65. digitalWrite(4, LOW);
  66. delay(1000); // delay for one second
  67. digitalWrite(2, LOW);
  68. delay(1000); // delay for one second
  69.  
  70.  
  71.  
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement