JAIAAKASHG

JAIAAKASHG

0-day streak
https://imgutil.s3.us-east-2.amazonaws.com/9be1787fe7b033d48445aea5861241c374cc731b851c17891af7a32d0805c316/6a4a9157-e025-4bb8-a189-b516d4000f8e.png
summer-of-making emoji
github emoji
https://imgutil.s3.us-east-2.amazonaws.com/6cc7c45860cda16d89c382f3c9648fe12eed51ca88a3a1ce924b89e0b7c288e8/7f6715a9-9e0a-44a7-8b79-bf570bc33ce6.png
github emoji
summer-of-making emoji
https://imgutil.s3.us-east-2.amazonaws.com/374db9ca96f0a04eb0cf44f321b814200fcfc86ca7999a0232fbc35067bd2449/056d6261-540b-4b7c-856f-8487bff7664a.png
summer-of-making emoji
github emoji
https://imgutil.s3.us-east-2.amazonaws.com/e7829f5c5c6b615b540223cd3a6c94350cace0a2db988f8832abd968376a7511/bfcce94a-ade7-4b40-87f2-635ce0489583.png
summer-of-making emoji
github emoji
https://imgutil.s3.us-east-2.amazonaws.com/53cfbbb6d1100e01ef8e5d0486a8d3a129fa0f265e9a0e84d655d4ff29f4331a/c87dcfa6-b641-49c5-949f-ed1d332e1db2.png
summer-of-making emoji
github emoji
https://imgutil.s3.us-east-2.amazonaws.com/8e2f05d8979f98e84246a94cd5638a72523768381154959504efd0d115343631/d8ccc44b-ff42-4fad-8b7f-c52431b05ffb.png
summer-of-making emoji
github emoji
https://imgutil.s3.us-east-2.amazonaws.com/d73a4e57d8fda2a944b29b424d12c02ffdf8b77f589ec99b4fdb4465c1633289/b8817e3d-cadc-479a-82b2-9e05ce551e66.png
https://imgutil.s3.us-east-2.amazonaws.com/6ebb4ea2d52c20dc53fb6c7e2698388782f1f8da614f497eb0a4324a797c060e/f7b9b19e-f88f-47d6-bfea-00472044459d.png
github emoji
summer-of-making emoji
https://imgutil.s3.us-east-2.amazonaws.com/7f67422ed0fed09a01990e06d89df800ba02f85fa2408f6812f98e5cdbce9d8c/33871676-ba91-4971-9315-a1f73d1ec6af.png
summer-of-making emoji
github emoji
https://imgutil.s3.us-east-2.amazonaws.com/80b1daa7efb3ff15d00abf1b5394e7f8f8d8bb8c2667a943151d514f21080b1d/6b3ec050-5456-47f1-b98d-c4b950c2ddd5.png
github emoji
summer-of-making emoji
https://imgutil.s3.us-east-2.amazonaws.com/d75aa63e6fde8003072e196607789f42bea208fb06eb240df308ee631f740c18/5585d226-9f76-469b-bba7-6aafcc0f7444.png
https://imgutil.s3.us-east-2.amazonaws.com/dacd7a29a6bb7c25ad1683c9ca7e61e4c497f860c1e8e9ba3a24ad81da23bb28/0de5d6e8-4da1-4ec7-bd16-78e1f51e29ca.png
summer-of-making emoji
github emoji
https://imgutil.s3.us-east-2.amazonaws.com/dadd44199b4c32699537d5182b66af13c00d5ab748ae06e8ca3089f079a0aff4/8ddf8951-cbfc-481b-99db-b9b0cf6fe33d.png
summer-of-making emoji
github emoji
https://imgutil.s3.us-east-2.amazonaws.com/d73a4e57d8fda2a944b29b424d12c02ffdf8b77f589ec99b4fdb4465c1633289/9e80d262-473a-46c0-8589-ecb524f32b07.png
summer-of-making emoji
github emoji
https://imgutil.s3.us-east-2.amazonaws.com/fe03aed48e190d26a7b46dbbdb1334ef35aff83db0c691645e2b3b1f41793fb9/6b3d30fc-f0c6-4011-9ec8-9c4375b86982.png
github emoji
summer-of-making emoji
https://imgutil.s3.us-east-2.amazonaws.com/d73a4e57d8fda2a944b29b424d12c02ffdf8b77f589ec99b4fdb4465c1633289/7159298d-9428-485a-9b48-f2a3850545a2.png
https://imgutil.s3.us-east-2.amazonaws.com/3a2207fd69a827f9b820152e4b75df758743efb978bb992b0a457c3fcca46120/0c56466f-9a4d-4ec3-8740-75896064100d.png
https://imgutil.s3.us-east-2.amazonaws.com/3cf3f4dc69156c25a3a96a5fbc866ee38ccd050f73eb4e3e2da0b1b20a313874/61ff85b2-40ef-4b2b-9505-6de65562fc7c.png
github emoji
summer-of-making emoji
https://imgutil.s3.us-east-2.amazonaws.com/d73a4e57d8fda2a944b29b424d12c02ffdf8b77f589ec99b4fdb4465c1633289/ab156f93-1d6c-48c0-b1b8-01cab653182c.png
https://imgutil.s3.us-east-2.amazonaws.com/9019d4c3138c955bbad599b5c2c36fe050a2915aa9352c4d7430089a0078750f/1b110c92-5a97-435b-84b1-6bd7f71c6820.png
github emoji
summer-of-making emoji
https://imgutil.s3.us-east-2.amazonaws.com/bf7fadc121584cf8bb49b9adb618ad55867344b6e533c7f13fdbc6061c4ac976/47c67f45-f995-4272-8576-ae16011209ca.png
summer-of-making emoji
github emoji
https://imgutil.s3.us-east-2.amazonaws.com/d708ce48cc984c7d2b9f15d37b400ee5a8f644f11437975c02039b421ff8bb66/0fd86e88-aa06-4a20-977f-c39f826f018f.png
https://imgutil.s3.us-east-2.amazonaws.com/59e0118db8386ae48f34684edc3d0aa9deabfab01e53df8457b18f9a43264de4/a0d98a5b-9fdf-4fed-8bd4-6b165c2f8a2c.png
summer-of-making emoji
github emoji
https://imgutil.s3.us-east-2.amazonaws.com/6e3cad453bc96acc705ae5f7f5871f7cf1d6e36323b7d63fed3a14295b624272/5d4b8395-29f9-4d2a-94b7-6d7a8a1a7937.png
https://imgutil.s3.us-east-2.amazonaws.com/95971afd6b403a441eebea944e27d05ad8e23d57ccfdf8c560b886ae68955889/102c664d-586c-427f-8930-ec070f7a690d.png
github emoji
summer-of-making emoji
https://imgutil.s3.us-east-2.amazonaws.com/c708b3171703672aea049aea38fedcf357f9a6ecaf3f9b6b6b963850bfdae572/14b25b0f-273f-4a91-867f-e1821fea989c.png
github emoji
summer-of-making emoji
https://imgutil.s3.us-east-2.amazonaws.com/9ddae020af1910c9cbd4838d8010cf99d7fce9fc3574b2a8c8ed68047794e709/714a5e48-fd7d-4a70-b4ed-1cab6dbee8ee.png
summer-of-making emoji
github emoji
https://imgutil.s3.us-east-2.amazonaws.com/dbc3cb7819665d4b7754268b358752b5ceab7159ce721a6135f49974ca3a4a7b/eafb92bf-1c10-429b-9e95-434e7a72d1be.png
https://imgutil.s3.us-east-2.amazonaws.com/a39d4673577ea72dc3483249c96e8416f315a64f2fa81b03eb09b7d0b77f0977/50023e28-cd5e-4194-abbc-1b1f9f372cc4.png
github emoji
summer-of-making emoji
https://imgutil.s3.us-east-2.amazonaws.com/06c55823fc6e8521f2a24b9ba0a48f81ffed3f73b361345a9832a41dd062ea02/711ad94a-450a-4650-b180-5ad010403f48.png
summer-of-making emoji
github emoji
https://imgutil.s3.us-east-2.amazonaws.com/c2612e3e007906534f08deb02bcc5e2552cfdb7551d0a98b73e54b24b235106e/c666b6ec-f091-480f-87d2-461467b5e70e.png
summer-of-making emoji
github emoji
https://imgutil.s3.us-east-2.amazonaws.com/68a0e635a723c5381898521505a9e7ecfbbcb3cb11e27c274ac421cbe1d6f3bc/25c179e2-f225-4258-bdd5-9e7c66debad3.png
summer-of-making emoji
github emoji
https://imgutil.s3.us-east-2.amazonaws.com/b48caefd5f94f337f7adfbf46242359c513b016eb1b5e7e67146bf09199aacc3/46d3994b-56ae-4600-83d2-139b442e551d.png
summer-of-making emoji
github emoji
https://imgutil.s3.us-east-2.amazonaws.com/27b11dacf64227e077069d3457402d26d8e9528e2d2784a8abd2c2498301c0e9/e3de02b0-058a-45a9-b3be-63001ec3a360.png
summer-of-making emoji
github emoji
https://imgutil.s3.us-east-2.amazonaws.com/c08d29e13f17a177701cbd01b23d43c83fcccd604f991f22ccea9c4fa0212b7d/76870a1d-f675-4eb2-a402-766b3f784ea9.png
https://imgutil.s3.us-east-2.amazonaws.com/647cb556a92ffeded98b35c480092b2c06f1b141cf5a511ddfaf82d4ba02ba65/87cfaaf1-ba6f-44c7-811e-8dcc864c77d4.png
github emoji
summer-of-making emoji
https://imgutil.s3.us-east-2.amazonaws.com/ad3ecc03af11f366cc02f4e2ca34539a22252771e4d3e77b9ce709052edadb02/791fb5c5-33ff-4a00-8f3b-a6a7ba0bf4d0.png
https://imgutil.s3.us-east-2.amazonaws.com/f4c9aabdb1ac9a54ad574da7ab8128aeff767fd01ca197e54cac394fa641267f/01aac3f6-5805-41a5-bee1-f86d9fe838e9.png
summer-of-making emoji
github emoji
https://imgutil.s3.us-east-2.amazonaws.com/a269de1298f38b0ef3fe20bead99cd18438a83898aa68655d6ab4f40e7981aad/022899bb-df3c-4e93-b78c-2c523d7c0422.png
summer-of-making emoji
github emoji
https://imgutil.s3.us-east-2.amazonaws.com/a8bd9be9bb307533c60576b5042f64938fb3fea17dd9477f1f42f9a5dcc46bd2/b9eb40b9-edc9-4d54-83fa-bc8a195a6d8f.png
github emoji
summer-of-making emoji
https://imgutil.s3.us-east-2.amazonaws.com/a8515b60967a0c4ebd26afeadcece7539b35b70b60f371bbe082750a65cc7fc9/baa04ed1-8c59-464c-9115-991bd61bb4d0.png
summer-of-making emoji
github emoji
https://imgutil.s3.us-east-2.amazonaws.com/a5c37cf01a87718aeb1e3ca3daaffc69ad30ac55d376cb8fb768066a7d8b95ee/d54fe3ef-dfef-4295-b6c2-d8841410dfa7.png
github emoji
summer-of-making emoji
https://imgutil.s3.us-east-2.amazonaws.com/82612b77f315a1efcdebf7cb4c3491484f130d19b69be49af61dc01e114f6849/aca12a43-9815-45b0-9e48-1aa5c8052dfe.png
summer-of-making emoji
github emoji
https://imgutil.s3.us-east-2.amazonaws.com/f143b4cf9844addefea54d4b19baf33578f64ea96ffa609818ba3d39fd64cc4b/47d1aebe-07dd-4dfa-b6f9-0e8af19bc36e.png
summer-of-making emoji
github emoji
https://imgutil.s3.us-east-2.amazonaws.com/50d35e10b9b19b82e2e9bf2981945507039046a6de8116b6db523871159d9f4b/6798807f-ab12-4475-b601-2eaa8c472b29.png
summer-of-making emoji
github emoji
https://imgutil.s3.us-east-2.amazonaws.com/22cdac4b64c5bb0ffb4693122f1e7f4d3b457ea6a6cbf7f06fc239a396a71bbb/b5f75618-a2e3-4ef2-aeb0-2081f8ee643f.png
github emoji
summer-of-making emoji
https://imgutil.s3.us-east-2.amazonaws.com/5eeaee014ade4d8600c1fbe2af3a1f3ef55efb80392c00e5f8387008d1182bcb/6c3394af-7f5d-4653-a629-1f04b00c379f.png
summer-of-making emoji
github emoji
https://imgutil.s3.us-east-2.amazonaws.com/7741213ec524c33c79ea9a5b3beb4c08ad7868139bff421846f835ceb96ce74f/a6a5cb01-a131-4962-bfa6-c36e5d5747b5.png
summer-of-making emoji
github emoji
https://imgutil.s3.us-east-2.amazonaws.com/40233d228daab27552fb7a1a3018c87b977ee1562028076eed5001d3fc527dc5/93cb00bc-4f94-4212-b7be-884372e525a7.png
github emoji
summer-of-making emoji
https://imgutil.s3.us-east-2.amazonaws.com/65e6816790c7c0186508b70287b78202bbeab8f4fef32ff4346e8835413977e6/8d143429-55f0-423a-acdb-4906436f8f87.png
https://imgutil.s3.us-east-2.amazonaws.com/0d890e420136a4e24840b5d0128b33ef110b694e8ec4a4da8ad4509299f0b4d8/8f9e70e9-7974-477f-8c56-caf31b3ca833.png
summer-of-making emoji
github emoji
https://imgutil.s3.us-east-2.amazonaws.com/8796d3eee34982c1d5c54838d679276d39db6119e4cb7e9b924007c54e2dfd4f/3f840479-8115-4e5e-addc-b3fa701e8197.png
summer-of-making emoji
github emoji
ultrafastparrot emoji
https://imgutil.s3.us-east-2.amazonaws.com/66b7b31a599bc0e15d427dfbe124bfe8fa0b3104a6e957bc1e5a3f552cc1f6ae/1acf3b91-25e4-458c-afda-50101c13cb56.png
summer-of-making emoji
github emoji
https://imgutil.s3.us-east-2.amazonaws.com/554ad2dbb34b9f82111769ed849b98b6621eb6e76be18bee79a45b8b621d6e71/a356c26e-f265-4f08-81aa-1f2dff9f74b0.png
summer-of-making emoji
github emoji
https://imgutil.s3.us-east-2.amazonaws.com/cbe9f5f407f39090ec80836c60e610bb3e3a5898094f56ce6fcb94603d616431/81d4d4ef-3e52-467a-acfb-31de805e1ce0.png
https://imgutil.s3.us-east-2.amazonaws.com/b97c767d905c694c6a8f708c5c8384ce060f3566b912977a2743b1e9e4f1db26/3a135537-f8c4-499e-8996-2bdc8215435d.png
github emoji
summer-of-making emoji
https://imgutil.s3.us-east-2.amazonaws.com/420a9ebae7a2e5da62980f106de010ca092e9925aa22a6aaafc57a76eaf534ad/6642f8e0-da05-4fd1-a4b4-57f58543c78e.png
github emoji
summer-of-making emoji
https://imgutil.s3.us-east-2.amazonaws.com/50cad5c5196cd60e5d4a406592532cca9fc2306782532f931f6c067ab772f17a/706f4514-3ad2-45b9-bd98-ef7326752ee2.png
https://imgutil.s3.us-east-2.amazonaws.com/d73a4e57d8fda2a944b29b424d12c02ffdf8b77f589ec99b4fdb4465c1633289/a1b19b91-fffe-462c-964f-e2a939f8b3f5.png
github emoji
summer-of-making emoji
https://imgutil.s3.us-east-2.amazonaws.com/9109572aece3a1ca00d85078b01be2b11f2c3db9553e13ec93c03b88c4c7102a/a5dd53d5-b17e-4bc2-aa37-d686d99321a4.png
https://scrapbook-into-the-redwoods.s3.amazonaws.com/b083ad8a-144f-4e7d-9122-63718afc3233-screenshot_26-6-2024_65530_localhost.jpeghttps://imgutil.s3.us-east-2.amazonaws.com/631a93c0ee7e53abf333bb3438316baf03248abecb6b7cd554e8afdd913b37aa/5afc31d1-ab4d-4b7d-93b7-5d0ef2d349b6.png
summer-of-making emoji
github emoji
from IPython.display import display, HTML display(HTML(''' !DOCTYPE html <html lang="en"> <head> <meta charset="UTF-8"> <title>Flappy Bird</title> <style> body { margin: 0; display: flex; justify-content: center; align-items: center; height: 100vh; background-color: #70C5CE; } canvas { border: 1px solid #000; background-color: #fff; } </style> </head> <body> <canvas id="flappyBirdCanvas" width="400" height="600"></canvas> <script> const canvas = document.getElementById('flappyBirdCanvas'); const context = canvas.getContext('2d'); const bird = { x: 50, y: 150, width: 20, height: 20, gravity: 0.6, lift: -15, velocity: 0, show: function() { context.fillStyle = 'green'; context.fillRect(this.x, this.y, this.width, this.height); }, update: function() { this.velocity += this.gravity; this.y += this.velocity; if (this.y > canvas.height - this.height) { this.y = canvas.height - this.height; this.velocity = 0; } if (this.y < 0) { this.y = 0; this.velocity = 0; } }, up: function() { this.velocity += this.lift; } }; const pipes = []; const pipeWidth = 40; const pipeGap = 150; let frameCount = 0; let score = 0; function drawPipes() { context.fillStyle = 'green'; for (let pipe of pipes) { context.fillRect(pipe.x, 0, pipeWidth, pipe.top); context.fillRect(pipe.x, pipe.bottom, pipeWidth, canvas.height - pipe.bottom); pipe.x -= 2; if (pipe.x + pipeWidth < 0) { pipes.shift(); score++; } if (bird.x < pipe.x + pipeWidth && bird.x + bird.width > pipe.x && (bird.y < pipe.top || bird.y + bird.height > pipe.bottom)) { resetGame(); } } } function addPipe() { let top = Math.floor(Math.random() * (canvas.height - pipeGap)); let bottom = top + pipeGap; pipes.push({x: canvas.width, top: top, bottom: bottom}); } function resetGame() { bird.y = 150; bird.velocity = 0; pipes.length = 0; frameCount = 0; score = 0; } function draw() { context.clearRect(0, 0, canvas.width, canvas.height); bird.show(); bird.update(); if (frameCount % 100 === 0) { addPipe(); } drawPipes(); context.fillStyle = 'black'; context.fillText('Score: ' + score, 10, 20); frameCount++; requestAnimationFrame(draw); } document.addEventListener('keydown', function(event) { if (event.code === 'Space') { bird.up(); } }); draw(); </script> </body> </html> '''))
https://scrapbook-into-the-redwoods.s3.amazonaws.com/c9d1904c-9a4e-4b45-ba93-1efb20d09e54-20240625_191143.jpg
Components Needed • Arduino Uno • 3 LEDs (Red, Yellow, Green) • 3 Resistors (220 ohms) • Buzzer • Ultrasonic Sensor (HC-SR04) • Breadboard and jumper wires Circuit Diagram 1. Green LED: ◦ Anode (long leg) to Arduino pin 7 through a 220-ohm resistor. ◦ Cathode (short leg) to GND. 2. Yellow LED: ◦ Anode (long leg) to Arduino pin 6 through a 220-ohm resistor. ◦ Cathode (short leg) to GND. 3. Red LED: ◦ Anode (long leg) to Arduino pin 5 through a 220-ohm resistor. ◦ Cathode (short leg) to GND. 4. Buzzer: ◦ Positive lead to Arduino pin 8. ◦ Negative lead to GND. 5. Ultrasonic Sensor (HC-SR04): ◦ VCC to 5V on the Arduino. ◦ GND to GND on the Arduino. ◦ Trig to Arduino pin 9. ◦ Echo to Arduino pin 10. CODE: Define pins for LEDs, Buzzer, and Ultrasonic Sensor const int redLED = 5; const int yellowLED = 6; const int greenLED = 7; const int buzzer = 8; const int trigPin = 9; const int echoPin = 10; // Timing constants in milliseconds const int buzzerTime = 1000; // 1 second void setup() { // Initialize the LED pins as outputs pinMode(redLED, OUTPUT); pinMode(yellowLED, OUTPUT); pinMode(greenLED, OUTPUT); pinMode(buzzer, OUTPUT); // Initialize the ultrasonic sensor pins pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); // Start with the green light digitalWrite(greenLED, HIGH); digitalWrite(yellowLED, LOW); digitalWrite(redLED, LOW); digitalWrite(buzzer, LOW); // Initialize Serial Monitor for debugging Serial.begin(9600); } void loop() { long duration, distance; // Send a 10us pulse to trigger the ultrasonic sensor digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); // Read the echo pin duration = pulseIn(echoPin, HIGH); // Calculate the distance distance = duration * 0.034 / 2; // Print the distance for debugging Serial.print("Distance: "); Serial.println(distance); // Control the LEDs and buzzer based on the distance if (distance > 30) { // Green light phase digitalWrite(greenLED, HIGH); digitalWrite(yellowLED, LOW); digitalWrite(redLED, LOW); digitalWrite(buzzer, LOW); } else if (distance > 10 && distance <= 30) { // Yellow light phase digitalWrite(greenLED, LOW); digitalWrite(yellowLED, HIGH); digitalWrite(redLED, LOW); digitalWrite(buzzer, LOW); } else if (distance <= 10) { // Red light phase with buzzer digitalWrite(greenLED, LOW); digitalWrite(yellowLED, LOW); digitalWrite(redLED, HIGH); digitalWrite(buzzer, HIGH); delay(buzzerTime); digitalWrite(buzzer, LOW); } delay(100); // Small delay to avoid excessive readings }
https://scrapbook-into-the-redwoods.s3.amazonaws.com/5191455e-f3f6-42d2-828f-2e26a3112dfd-1000053370.jpg
summer-of-making emoji
hardware emoji
dino-debugging emoji
pcb emoji
goose-honk-technologist emoji
Requirements ESP32 board LED Resistor (220 ohms) Breadboard and jumper wires Arduino IDE Circuit Diagram LED Anode (long leg): Connect to GPIO 23 (pin G23) on the ESP32. LED Cathode (short leg): Connect to one end of a 220-ohm resistor. Other end of the resistor: Connect to GND on the ESP32. Code First, make sure you have the necessary libraries. You can install the WiFi library for the ESP32 from the Arduino Library Manager. Here's the code to create a web server and control an LED: cpp Copy code #include <WiFi.h> // Replace with your network credentials const char ssid = "YOUR_SSID"; const char password = "YOURPASSWORD"; // Set web server port number to 80 WiFiServer server(80); // Variable to store the HTTP request String header; // LED GPIO pin const int ledPin = 23; bool ledState = false; void setup() { // Initialize the LED pin as an output pinMode(ledPin, OUTPUT); digitalWrite(ledPin, LOW); // Start Serial communication for debugging purposes Serial.begin(115200); // Connect to Wi-Fi network Serial.print("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, password); while (WiFi.status() != WLCONNECTED) { delay(1000); Serial.print("."); } // Print the local IP address Serial.println(""); Serial.println("WiFi connected."); Serial.println("IP address: "); Serial.println(WiFi.localIP()); // Start the server server.begin(); } void loop() { WiFiClient client = server.available(); // Listen for incoming clients if (client) { // If a new client connects, Serial.println("New Client."); // print a message out in the serial port String currentLine = ""; // make a String to hold incoming data from the client while (client.connected()) { // loop while the client's connected if (client.available()) { // if there's bytes to read from the client, char c = client.read(); // read a byte, then Serial.write(c); // print it out the serial monitor header += c; if (c == '\n') { // if the byte is a newline character // if the current line is blank, you got two newline characters in a row. // that's the end of the client HTTP request, so send a response: if (currentLine.length() == 0) { // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK) // and a content-type so the client knows what's coming, then a blank line: client.println("HTTP/1.1 200 OK"); client.println("Content-type:text/html"); client.println("Connection: close"); client.println(); // Display the HTML web page client.println("!DOCTYPE html<html>"); client.println("<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">"); client.println("<link rel=\"icon\" href=\"data:,\">"); // CSS to style the on/off buttons client.println("<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}"); client.println(".button { background-color: #4CAF50; border: none; color: white; padding: 16px 40px;"); client.println("text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;}"); client.println(".button2 {background-color: #555555;}</style></head>"); // Web Page Heading client.println("<body><h1>ESP32 Web Server</h1>"); // Display current state, and ON/OFF buttons for LED if (ledState) { client.println("<p>LED is ON</p>"); client.println("<p><a href=\"/ledOff\"><button class=\"button button2\">OFF</button></a></p>"); } else { client.println("<p>LED is OFF</p>"); client.println("<p><a href=\"/ledOn\"><button class=\"button\">ON</button></a></p>"); } client.println("</body></html>"); // The HTTP response ends with another blank line client.println(); // Break out of the while loop break; } else { // if you got a newline, then clear currentLine currentLine = ""; } } else if (c != '\r') { // if you got anything else but a carriage return character, currentLine += c; // add it to the end of the currentLine } // Check to see if the client request was "GET /ledOn" or "GET /ledOff": if (currentLine.endsWith("GET /ledOn")) { ledState = true; digitalWrite(ledPin, HIGH); } if (currentLine.endsWith("GET /ledOff")) { ledState = false; digitalWrite(ledPin, LOW); } } } // Clear the header variable header = ""; // Close the connection client.stop(); Serial.println("Client disconnected."); Serial.println(""); } } Explanation WiFi Setup: The ssid and password variables store your WiFi credentials. The WiFi.begin(ssid, password) function connects to your WiFi network. The while (WiFi.status() != WL_CONNECTED) loop waits until the ESP32 connects to the WiFi. Web Server Setup: WiFiServer server(80) creates a web server on port 80. server.begin() starts the server. Handling Client Requests: WiFiClient client = server.available() waits for a client to connect. The server reads the HTTP request and checks if the client requested to turn the LED on or off. Based on the request, it changes the state of the LED using digitalWrite(ledPin, HIGH) or digitalWrite(ledPin, LOW). Generating HTML Response: The HTML response is generated and sent back to the client. The HTML contains buttons to turn the LED on and off. Loop: The loop() function continuously listens for incoming client connections and handles their requests. Uploading the Code Connect your ESP32 board to your computer via USB. Select the correct board and port in the Arduino IDE: Go to Tools -> Board, and select your ESP32 model (e.g., "ESP32 Dev Module"). Go to Tools -> Port, and select the appropriate COM port for your ESP32. Click the Upload button in the Arduino IDE to upload the code to your ESP32. Using the Web Server Open the Serial Monitor in the Arduino IDE to see the IP address assigned to your ESP32. Open a web browser and enter the IP address in the address bar (e.g., 192.168.1.100). You should see a web page with buttons to turn the LED on and off. This setup allows you to control the LED connected to your ESP32 from any device on the same WiFi network using a web browser.
https://scrapbook-into-the-redwoods.s3.amazonaws.com/5a92d57c-1801-44c8-82ec-a5656f394020-1000053349.jpg
summer-of-making emoji
dino-debugging emoji
pcb emoji
hardware emoji
goose-honk-technologist emoji
c emoji
#include &lt;WiFi.h&gt; #include &lt;WebServer.h&gt; // Replace with your network credentials const char ssid = "your_SSID"; const char password = "yourPASSWORD"; // Create an instance of the web server on port 80 WebServer server(80); // Define the pin connected to the buzzer const int buzzerPin = 25; // Define a melody and its duration const int melody[] = {262, 294, 330, 349, 392, 440, 494, 523}; const int noteDurations[] = {4, 4, 4, 4, 4, 4, 4, 4}; // HTML content to be served String getIndexHtml() { return R"rawliteral( <!DOCTYPE html> &lt;html&gt; &lt;head&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt; &lt;title&gt;ESP32 Web Server&lt;/title&gt; &lt;style&gt; body { font-family: Arial, sans-serif; text-align: center; } h1 { color: #333; } button { padding: 10px 20px; font-size: 16px; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;ESP32 Web Server&lt;/h1&gt; &lt;button onclick="playMelody()"&gt;Play Melody&lt;/button&gt; &lt;p id="status"&gt;&lt;/p&gt; &lt;script&gt; function playMelody() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 &&amp; this.status == 200) { document.getElementById("status").innerHTML = this.responseText; } }; xhttp.open("GET", "play", true); xhttp.send(); } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; )rawliteral"; } // Function to play the melody on the buzzer void playMelody() { for (int thisNote = 0; thisNote &lt; 8; thisNote++) { int noteDuration = 1000 / noteDurations[thisNote]; tone(buzzerPin, melody[thisNote], noteDuration); int pauseBetweenNotes = noteDuration * 1.30; delay(pauseBetweenNotes); noTone(buzzerPin); } } // Handle the root URL void handleRoot() { server.send(200, "text/html", getIndexHtml()); } // Handle the play melody request void handlePlay() { playMelody(); server.send(200, "text/plain", "Playing melody..."); } void setup() { // Start the serial communication Serial.begin(115200); // Set the buzzer pin as output pinMode(buzzerPin, OUTPUT); // Connect to Wi-Fi WiFi.begin(ssid, password); while (WiFi.status() != WLCONNECTED) { delay(1000); Serial.println("Connecting to WiFi..."); } Serial.println("Connected to WiFi"); // Print the IP address Serial.println(WiFi.localIP()); // Define routes server.on("/", handleRoot); server.on("/play", handlePlay); // Start the server server.begin(); Serial.println("Server started"); } void loop() { // Handle client requests server.handleClient(); }
https://scrapbook-into-the-redwoods.s3.amazonaws.com/f5965782-0a26-415c-8481-882b0eabb5c2-20240624_204522.jpg
summer-of-making emoji
#define BUZZERPIN 23 // G23 Pin #define BUZZERGROUND 2 // G2 Pin int melody[] = { NOTEC4, NOTED4, NOTEE4, NOTEF4, NOTEG4, NOTEA4, NOTEB4, NOTEC5 }; // note durations: 4 = quarter note, 8 = eighth note, etc.: int noteDurations[] = { 4, 4, 4, 4, 4, 4, 4, 4 }; void setup() { pinMode(BUZZERPIN, OUTPUT); pinMode(BUZZERGROUND, OUTPUT); digitalWrite(BUZZERGROUND, LOW); // Connect G2 to ground // iterate over the notes of the melody: for (int thisNote = 0; thisNote &lt; 8; thisNote++) { // to calculate the note duration, take one second divided by the note type. // e.g., quarter note = 1000 / 4, eighth note = 1000 / 8, etc. int noteDuration = 1000 / noteDurations[thisNote]; tone(BUZZERPIN, melody[thisNote], noteDuration); // to distinguish the notes, set a minimum time between them. // the note's duration + 30% seems to work well: int pauseBetweenNotes = noteDuration * 1.30; delay(pauseBetweenNotes); // stop the tone playing: noTone(BUZZER_PIN); } } void loop() { // no need to repeat the melody. }
https://scrapbook-into-the-redwoods.s3.amazonaws.com/0b4f0293-374a-40e8-877a-e96d111bfba1-20240624_195707.jpg
summer-of-making emoji
#include &lt;ESP8266WiFi.h&gt; #include &lt;ESP8266WebServer.h&gt; const char ssid = "YourSSID"; const char password = "YourPassword"; const int trigPin = D1; const int echoPin = D2; const int buzzerPin = D3; ESP8266WebServer server(80); void setup() { pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); pinMode(buzzerPin, OUTPUT); Serial.begin(115200); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.println("Connecting to WiFi..."); } Serial.println("WiFi connected"); Serial.println("IP address: "); Serial.println(WiFi.localIP()); server.on("/", handleRoot); server.on("/activate", handleActivate); server.begin(); Serial.println("HTTP server started"); } void loop() { server.handleClient(); long duration, distance; digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); distance = (duration / 2) / 29.1; // Calculate distance in cm Serial.print("Distance: "); Serial.print(distance); Serial.println(" cm"); if (distance &lt; 10) { tone(buzzerPin, 1000); // Activate buzzer if object is too close } else { noTone(buzzerPin); } delay(500); } void handleRoot() { long duration, distance; digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); distance = (duration / 2) / 29.1; // Calculate distance in cm String html = "&lt;html&gt;&lt;body&gt;"; html += "&lt;h1&gt;Distance: "; html += distance; html += " cm&lt;/h1&gt;"; html += "&lt;form action='/activate' method='get'&gt;&lt;input type='submit' value='Activate Buzzer'&gt;&lt;/form&gt;"; html += "&lt;/body&gt;&lt;/html&gt;"; server.send(200, "text/html", html); } void handleActivate() { server.send(200, "text/plain", "Buzzer activated!"); tone(buzzerPin, 1000); // Activate the buzzer delay(1000); // Buzz for 1 second noTone(buzzerPin); // Turn off the buzzer }
https://scrapbook-into-the-redwoods.s3.amazonaws.com/161d1404-ee79-4917-9cfb-9f1ccf24fa0e-image.png
summer-of-making emoji
#include &lt;ESP8266WiFi.h&gt; // Replace with your network credentials const char ssid = "Airtel_PRAKASH"; const char password = "9941113669"; // Set web server port number to 80 WiFiServer server(80); // Variable to store the HTTP request String header; // Current state of the buzzer String buzzerState = "off"; // Assign GPIO pin for the buzzer const int buzzerPin = D2; void setup() { Serial.begin(115200); pinMode(buzzerPin, OUTPUT); digitalWrite(buzzerPin, LOW); // Connect to Wi-Fi network Serial.print("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.print("."); } // Print local IP address and start web server Serial.println(""); Serial.println("WiFi connected."); Serial.println("IP address: "); Serial.println(WiFi.localIP()); server.begin(); } void loop() { WiFiClient client = server.available(); // Listen for incoming clients if (client) { // If a new client connects, Serial.println("New Client."); // print a message out in the serial port String currentLine = ""; // make a String to hold incoming data from the client while (client.connected()) { // loop while the client's connected if (client.available()) { // if there's bytes to read from the client, char c = client.read(); // read a byte, then Serial.write(c); // print it out the serial monitor header += c; if (c == '\n') { // if the byte is a newline character if (currentLine.length() == 0) { // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK) // and a content-type so the client knows what's coming, then a blank line: client.println("HTTP/1.1 200 OK"); client.println("Content-type:text/html"); client.println("Connection: close"); client.println(); // Display the HTML web page client.println("!DOCTYPE html&lt;html&gt;"); client.println("&lt;head&gt;&lt;title&gt;ESP8266 Buzzer Control&lt;/title&gt;&lt;/head&gt;"); client.println("&lt;body&gt;&lt;h1&gt;ESP8266 Buzzer Control&lt;/h1&gt;"); client.println("&lt;p&gt;Buzzer State: " + buzzerState + "&lt;/p&gt;"); client.println("&lt;p&gt;&lt;a href=\"/H\"&gt;&lt;button&gt;ON&lt;/button&gt;&lt;/a&gt;&lt;/p&gt;"); client.println("&lt;p&gt;&lt;a href=\"/L\"&gt;&lt;button&gt;OFF&lt;/button&gt;&lt;/a&gt;&lt;/p&gt;"); client.println("&lt;/body&gt;&lt;/html&gt;"); // The HTTP response ends with another blank line client.println(); break; } else { // if you got a newline, then clear currentLine currentLine = ""; } } else if (c != '\r') { // if you got anything else but a carriage return character, currentLine += c; // add it to the end of the currentLine } // Check if the client is requesting the buzzer to be turned on or off if (header.indexOf("GET /H") &gt;= 0) { Serial.println("Buzzer ON"); buzzerState = "on"; digitalWrite(buzzerPin, HIGH); } else if (header.indexOf("GET /L") &gt;= 0) { Serial.println("Buzzer OFF"); buzzerState = "off"; digitalWrite(buzzerPin, LOW); } } } // Clear the header variable header = ""; // Close the connection client.stop(); Serial.println("Client disconnected."); Serial.println(""); } }
https://scrapbook-into-the-redwoods.s3.amazonaws.com/1f49c3db-7289-4bfb-bfa8-ea4727ebb4c9-image.png
DONE
https://scrapbook-into-the-redwoods.s3.amazonaws.com/02809c21-9b8a-463e-8386-b56efb036466-whatsapp_image_2024-06-23_at_17.18.13_e9f4c7e5.jpg