Menu
Index
Engineering
Entertainment
Literature
Miscellaneous
Contact
Search
tiktok.com/@pkvi.xyz
buymeacoffee.com/pkvi
scored.co/u/pkvi_halfkdeltaxsq
Miter
Why Ayh?
Miter
@pkvi
"...may not meet professional standards."
321 miters
122 tenons
Subscribe
0.00186
Arduino Wave Generator Tank


Arduino Nano
(2) 9G Servo
10K Potentiometer
RGB LED
(3) 1K Resistor
5V Power Supply
Acrylic



  1. // Arduino Wave Tank
  2. // pkvi
  3. #include <Servo.h>
  4. Servo left;
  5. Servo right;
  6. int pos = 20;
  7. int post = 160;
  8. int back = 20;
  9. int forward = 160;
  10. int red = 6;
  11. int green = 5;
  12. int blue = 4;
  13. int slow = 8;
  14. int fast = 4;
  15. void setup() {
  16. Serial.begin(9600);
  17. left.attach(2);
  18. right.attach(3);
  19. pinMode(red, OUTPUT);
  20. pinMode(green, OUTPUT);
  21. pinMode(blue, OUTPUT);
  22. left.write(back);
  23. right.write(back);
  24. digitalWrite(green, HIGH);
  25. delay(1000);
  26. digitalWrite(green, LOW);
  27. delay(1000);
  28. digitalWrite(red, HIGH);
  29. delay(1000);
  30. digitalWrite(red, LOW);
  31. delay(1000);
  32. }
  33. void loop() {
  34. int pent = analogRead(A0);
  35. Serial.println(pent);
  36. if (pent < 200) {
  37. digitalWrite(blue, HIGH);
  38. digitalWrite(red, LOW);
  39. digitalWrite(green, LOW);
  40. for (pos = back; pos <= forward; pos += 1) {
  41. left.write(pos);
  42. right.write(pos);
  43. delay(slow);
  44. }
  45. for (pos = forward; pos >= back; pos -= 1) {
  46. left.write(pos);
  47. right.write(pos);
  48. delay(slow);
  49. }
  50. }
  51. else if (pent > 200 && pent < 450) {
  52. digitalWrite(blue, LOW);
  53. digitalWrite(red, HIGH);
  54. digitalWrite(green, LOW);
  55. for (pos = back; pos <= forward; pos += 1) {
  56. left.write(pos);
  57. right.write(pos);
  58. delay(fast);
  59. }
  60. for (pos = forward; pos >= back; pos -= 1) {
  61. left.write(pos);
  62. right.write(pos);
  63. delay(fast);
  64. }
  65. }
  66. else if (pent > 450 && pent < 700) {
  67. digitalWrite(blue, LOW);
  68. digitalWrite(red, LOW);
  69. digitalWrite(green, HIGH);
  70. for (pos = back; pos <= forward; pos += 1) {
  71. post = map(pos, 20, 160, 160, 20);
  72. left.write(pos);
  73. right.write(post);
  74. delay(slow);
  75. }
  76. for (pos = forward; pos >= back; pos -= 1) {
  77. post = map(pos, 160, 20, 20, 160);
  78. left.write(pos);
  79. right.write(post);
  80. delay(slow);
  81. }
  82. }
  83. else if (pent > 700 && pent < 1023) {
  84. digitalWrite(blue, LOW);
  85. digitalWrite(red, HIGH);
  86. digitalWrite(green, LOW);
  87. for (pos = back; pos <= forward; pos += 1) {
  88. post = map(pos, 20, 160, 160, 20);
  89. left.write(pos);
  90. right.write(post);
  91. delay(fast);
  92. }
  93. for (pos = forward; pos >= back; pos -= 1) {
  94. post = map(pos, 160, 20, 20, 160);
  95. left.write(pos);
  96. right.write(post);
  97. delay(fast);
  98. }
  99. }
  100. }

Speed Adjustable
  1. // Arduino Wave Tank II
  2. // pkvi
  3. #include <Servo.h>
  4. Servo left;
  5. Servo right;
  6. int pos = 20;
  7. int back = 20;
  8. int forward = 160;
  9. int spe = 15;
  10. int red = 6;
  11. int green = 5;
  12. int blue = 4;
  13. void setup() {
  14. Serial.begin(9600);
  15. left.attach(2);
  16. right.attach(3);
  17. pinMode(red, OUTPUT);
  18. pinMode(green, OUTPUT);
  19. pinMode(blue, OUTPUT);
  20. left.write(back);
  21. right.write(back);
  22. digitalWrite(green, HIGH);
  23. delay(1000);
  24. digitalWrite(green, LOW);
  25. delay(1000);
  26. digitalWrite(red, HIGH);
  27. delay(1000);
  28. digitalWrite(red, LOW);
  29. delay(1000);
  30. }
  31. void loop() {
  32. int pent = analogRead(A0);
  33. Serial.println(pent);
  34. spe = map(pent, 0, 1023, 15, 1);
  35. if (spe >= 10) {
  36. digitalWrite(green, HIGH);
  37. digitalWrite(blue, LOW);
  38. digitalWrite(red, LOW);
  39. }
  40. else if (spe < 10 && spe >= 5) {
  41. digitalWrite(green, LOW);
  42. digitalWrite(blue, HIGH);
  43. digitalWrite(red, LOW);
  44. }
  45. else if (spe < 5 && spe >= 1) {
  46. digitalWrite(green, LOW);
  47. digitalWrite(blue, LOW);
  48. digitalWrite(red, HIGH);
  49. }
  50. for (pos = back; pos <= forward; pos += 1) {
  51. left.write(pos);
  52. right.write(pos);
  53. delay(spe);
  54. }
  55. for (pos = forward; pos >= back; pos -= 1) {
  56. left.write(pos);
  57. right.write(pos);
  58. delay(spe);
  59. }
  60. }