Arduino Water Boarding


  1. // Arduino Water Board
  2. // pkvi
  3. #include <Servo.h>
  4. Servo spigot;
  5. Servo rightarm;
  6. // Servo Position
  7. int spigpos = 45;
  8. int armpos = 15;
  9. // Resting State
  10. float lieset = 0;
  11. int lierec = 0;
  12. int lietotal = 0;
  13. int lieavg = 0;
  14. int lienew = 0;
  15. // Variance
  16. int spvar = 20;
  17. int liepin = A0;
  18. // Valve
  19. int valve = 8;
  20. // LEDs
  21. int blue = 13;
  22. int green = 12;
  23. int red = 11;
  24. void setup() {
  25. spigot.attach(9); // Spigot
  26. rightarm.attach(10); // Rag Arm
  27. pinMode(valve, OUTPUT);
  28. pinMode(blue, OUTPUT);
  29. pinMode(green, OUTPUT);
  30. pinMode(red, OUTPUT);
  31. Serial.begin(9600);
  32. // Reset Position
  33. spigot.write(45);
  34. delay(1500);
  35. rightarm.write(15);
  36. digitalWrite(valve, LOW);
  37. // Obtain Resting State -- Calibration
  38. for (int x = 0; x < 100; x++) {
  39. lieavg = analogRead(liepin);
  40. lietotal = lietotal + lieavg;
  41. }
  42. lieset = round(lietotal / 100);
  43. }
  44. void loop() {
  45. Serial.println(analogRead(liepin));
  46. digitalWrite(red, LOW);
  47. digitalWrite(green, LOW);
  48. digitalWrite(blue, HIGH);
  49. // Jacob Communication
  50. if (Serial.available()) {
  51. char ser = Serial.read();
  52. switch (ser) {
  53. case '1':
  54. detect();
  55. break;
  56. }
  57. }
  58. delay(20);
  59. }
  60. void detect() {
  61. // Query GV Response
  62. for (int x = 0; x < 50; x++) {
  63. lieavg = analogRead(liepin);
  64. lietotal = lietotal + lieavg;
  65. Serial.println(analogRead(liepin));
  66. delay(2);
  67. }
  68. lienew = round(lietotal / 50);
  69. // Lie or Truth?
  70. // Jacob Polls Serial Response
  71. if (lienew + spvar > lieset || lienew - spvar > lieset) {
  72. Serial.println("Lie");
  73. torture();
  74. }
  75. else if (lieset > lienew + spvar || lieset > lienew - spvar) {
  76. Serial.println("Truth");
  77. truth();
  78. }
  79. else {
  80. Serial.println("Unclear")
  81. detect();
  82. }
  83. }
  84. void torture() {
  85. digitalWrite(red, HIGH);
  86. digitalWrite(green, LOW);
  87. digitalWrite(blue, LOW);
  88. for (armpos = 15; armpos <= 85; armpos += 1) {
  89. rightarm.write(armpos);
  90. delay(15);
  91. }
  92. for (spigpos = 45; spigpos <= 90; spigpos += 1) {
  93. spigot.write(spigpos);
  94. delay(15);
  95. }
  96. delay(1500);
  97. digitalWrite(valve, HIGH);
  98. delay(10000);
  99. digitalWrite(valve, LOW);
  100. spigot.write(45);
  101. delay(1500);
  102. rightarm.write(15);
  103. }
  104. void truth() {
  105. digitalWrite(red, LOW);
  106. digitalWrite(green, HIGH);
  107. digitalWrite(blue, LOW);
  108. }

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.01153