Dr. Jack and Mr. O'Lantern


  1. // Dr. Jack Mr. O'Lantern
  2. // pkvi
  3. #include "Servo.h"
  4. Servo jack;
  5. Servo pour;
  6. const int red = 4;
  7. const int blue = 5;
  8. const int fan = 2;
  9. const int sensor = A0;
  10. // Trigger Distance in CM
  11. const int dist = 90;
  12. void setup() {
  13. jack.attach(7);
  14. jack.write(0);
  15. pour.attach(3);
  16. pour.write(10);
  17. pinMode(red, OUTPUT);
  18. pinMode(blue, OUTPUT);
  19. pinMode(fan, OUTPUT);
  20. Serial.begin(9600);
  21. digitalWrite(red, HIGH);
  22. digitalWrite(blue, LOW);
  23. delay(2500);
  24. digitalWrite(red, LOW);
  25. digitalWrite(blue, HIGH);
  26. delay(2500);
  27. }
  28. void loop() {
  29. jack.write(0);
  30. pour.write(10);
  31. digitalWrite(red, HIGH);
  32. digitalWrite(blue, LOW);
  33. digitalWrite(fan, LOW);
  34. delay(20);
  35. digitalWrite(red, LOW);
  36. delay(40);
  37. digitalWrite(red, HIGH);
  38. long prox, proxcm;
  39. pinMode(sensor, OUTPUT);
  40. digitalWrite(sensor, HIGH);
  41. delayMicroseconds(6);
  42. digitalWrite(sensor, LOW);
  43. pinMode(sensor, INPUT);
  44. prox = pulseIn(sensor, HIGH);
  45. proxcm = mtc(prox);
  46. Serial.println(proxcm);
  47. if (proxcm < dist) {
  48. digitalWrite(red, LOW);
  49. pour.write(75);
  50. jack.write(130);
  51. delay(100);
  52. digitalWrite(fan, HIGH);
  53. delay(2000);
  54. digitalWrite(blue, HIGH);
  55. delay(10000);
  56. }
  57. delay(100);
  58. }
  59. long mtc(long ms) {
  60. return ms / 29 / 2;
  61. }

Menu
Index
Engineering
Entertainment
Literature
Miscellaneous
Contact
Search
tiktok.com/@pkvi.xyz
Why Ayh?
Miter
Miter
@pkvi
"...may not meet professional standards."
2,363 miters
123 tenons
Subscribe
0.00429