NodeMCU Voice Kitchen Faucet


NodeMCU ESP8266 ESP-12E V2
(2) 9G Micro Servo
5V Power Supply
Jacob AI (Proprietary)
PLA (3D Printer)



  1. // Voice Kitchen Faucet V.0.1 (NodeMCU)
  2. // pkvi
  3. #include <ESP8266WiFi.h>
  4. #include <Servo.h>
  5. const char* ssid = "ssid";
  6. const char* pass = "password";
  7. WiFiServer server(80);
  8. Servo left;
  9. Servo right;
  10. // Servo Pins
  11. const int ser_l = D6;
  12. const int ser_r = D5;
  13. // Version 2.0 would map() distance
  14. // between off and peak temp ..
  15. // Off
  16. int l_off = 60;
  17. int r_off = 110;
  18. // Hot
  19. int hfl = 70;
  20. int hfr = 50;
  21. int hol = 60;
  22. int hor = 10;
  23. // Mix
  24. int mfl = 90;
  25. int mfr = 75;
  26. int mol = 130;
  27. int mor = 35;
  28. // Cold
  29. int cfl = 110;
  30. int cfr = 90;
  31. int col = 160;
  32. int cor = 90;
  33. // Position
  34. int pl = 70;
  35. int pr = 90;
  36. // LED
  37. int led = D0;
  38. void setup() {
  39. Serial.begin(115200);
  40. pinMode(led, OUTPUT);
  41. digitalWrite(led, LOW);
  42. left.attach(ser_l);
  43. right.attach(ser_r);
  44. left.write(l_off);
  45. right.write(r_off);
  46. // Connect
  47. Serial.println(ssid);
  48. WiFi.begin(ssid, pass);
  49. while (WiFi.status() != WL_CONNECTED) {
  50. delay(500);
  51. Serial.print(".");
  52. }
  53. Serial.println("Connected");
  54. server.begin();
  55. Serial.print("http://");
  56. Serial.print(WiFi.localIP());
  57. Serial.println("/");
  58. }
  59. void loop() {
  60. // Check
  61. WiFiClient client = server.available();
  62. if (!client) {
  63. return;
  64. }
  65. // Wait
  66. while (!client.available()) {
  67. delay(1);
  68. }
  69. // Read
  70. String query = client.readStringUntil('\r');
  71. client.flush();
  72. if (query.indexOf("/hot=50") != -1) {
  73. hot(50);
  74. }
  75. if (query.indexOf("/hot=100") != -1) {
  76. hot(100);
  77. }
  78. if (query.indexOf("/cold=50") != -1) {
  79. cold(50);
  80. }
  81. if (query.indexOf("/cold=100") != -1) {
  82. cold(100);
  83. }
  84. if (query.indexOf("/mix=50") != -1) {
  85. mix(50);
  86. }
  87. if (query.indexOf("/mix=100") != -1) {
  88. mix(100);
  89. }
  90. if (query.indexOf("/off") != -1) {
  91. off();
  92. }
  93. delay(1);
  94. }
  95. void off() {
  96. left.write(l_off);
  97. right.write(r_off);
  98. delay(5);
  99. }
  100. void hot(int q) {
  101. if (q == 50) {
  102. pl = hfl;
  103. pr = hfr;
  104. } else if (q == 100) {
  105. pl = hol;
  106. pr = hor;
  107. }
  108. left.write(pl);
  109. right.write(pr);
  110. delay(5);
  111. }
  112. void mix(int q) {
  113. if (q == 50) {
  114. pl = mfl;
  115. pr = mfr;
  116. } else if (q == 100) {
  117. pl = mol;
  118. pr = mor;
  119. }
  120. left.write(pl);
  121. right.write(pr);
  122. delay(5);
  123. }
  124. void cold(int q) {
  125. if (q == 50) {
  126. pl = cfl;
  127. pr = cfr;
  128. } else if (q == 100) {
  129. pl = col;
  130. pr = cor;
  131. }
  132. left.write(pl);
  133. right.write(pr);
  134. delay(5);
  135. }

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