Advertisement
marquessamackenzie

DIGF 2002 - Arduino Blink Assignment 17/09/19

Sep 17th, 2019
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. /*
  2. Project Name: Arduino Blink Assignment
  3. Name: Marquessa MacKenzie
  4. Date: Sept 17th, 2019
  5. Project: DIGF 2002 - Physical Computing Week Two Inclass Assignment
  6. Resources: https://www.arduino.cc/en/tutorial/fading
  7. https://www.arduino.cc/reference/en/language/functions/digital-io/pinmode/
  8. https://www.arduino.cc/en/Tutorial/Blink
  9. */
  10.  
  11. void setup() {
  12. // put your setup code here, to run once:
  13. pinMode(7, OUTPUT);//Setting 7 to output for blink
  14. pinMode(2, OUTPUT);//Setting 2 to output for blink
  15. pinMode(9, OUTPUT);//Setting 9 to output for blink and fade
  16. }
  17.  
  18. void loop() {
  19. // put your main code here, to run repeatedly:
  20. digitalWrite(7, HIGH); //This turns the green LED on
  21. delay(1000); //wait for one second
  22. digitalWrite(7, LOW); //This turns the green LED off
  23. delay(1000); //wait for a second
  24. digitalWrite(7, HIGH); //This turns the green LED on
  25. delay(500); //wait for half of a second
  26. digitalWrite(7, LOW); //This turns the green LED off
  27. delay(500); //wait for half of a second
  28. digitalWrite(7, HIGH); //This turns the green LED on
  29. delay(1000); //wait for one second
  30. digitalWrite(7, LOW); //This turns the green LED off
  31. delay(1000); //wait for a second
  32.  
  33. digitalWrite(2, HIGH); //This turns the white LED on
  34. delay(666); //wait for two thirds of a second
  35. digitalWrite(2, LOW); //This turns the white LED off
  36. delay(333); //wait for a third of a second
  37. digitalWrite(2, HIGH); //This turns the white LED on
  38. delay(666); //wait for two thirds second
  39. digitalWrite(2, LOW); //This turns the white LED off
  40. delay(333); //wait for one third of a second
  41. digitalWrite(2, HIGH); //This turns the white LED on
  42. delay(666); //wait for two thrids of a second
  43. digitalWrite(2, LOW); //This turns the white LED off
  44. delay(333); //wait for one third of a second
  45.  
  46.  
  47. digitalWrite(9, HIGH); //This turns the red LED on
  48. delay(750); //Wait for three quarters of a second
  49. digitalWrite(9, LOW); //This turns the red LED off
  50. delay(250); //Wait for a quarter of a second
  51. digitalWrite(9, HIGH); //This turns the red LED on
  52. delay(750); //Wait for three quarters of a second
  53. digitalWrite(9, LOW); //This turns the red LED off
  54. delay(250); //Wait for a quarter of a second
  55. digitalWrite(9, HIGH); //This turns the red LED on
  56. delay(750); //Wait for three quarters of a second
  57. digitalWrite(9, LOW); //This turns the red LED off
  58. delay(250); //Wait for a quarter of a second
  59.  
  60. //The following code controls the analog fade on the red LED at the end of the sequence:
  61. //fade in from min to max in increments of 5 points:
  62. for (int fadeValue = 0 ; fadeValue <= 225; fadeValue += 5)
  63. {
  64. //sets the value (range from 0 to 225)
  65. analogWrite(9, fadeValue);
  66. //wait for 30 milliseconds to see the dimming effect
  67. delay(100);
  68. }
  69.  
  70. //fade out from min to max in increments of 5 points:
  71. for (int fadeValue = 225 ; fadeValue >= 0; fadeValue -= 5)
  72. {
  73. //sets the value (range from 0 to 225)
  74. analogWrite(9, fadeValue);
  75. //wait for 30 milliseconds to see the dimming effect
  76. delay(100);
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement