How to make DIY Blinking Heart!

in DIYHub23 days ago (edited)

Intro

Hey everyone, I am back with another DIY tutorial, since this months theme is about the special valentine's day so I decided to once again use the power of my favorited microcontroller esp32 to create a blinking heart using some LEDs on a box. Make sure to watch the final result on the video attached down here.

1111.png

Materials

  • Electrical junction box
  • 17 red 3mm LEDs
  • 220 ohm resistors
  • ESP32 microcontrollers
  • Connection wires
  • Breadboard
  • Drill
  • Glue
  • paper

Steps

For getting started I needed a surface to put all the LEDs on it and place them in form of a heart, so after looking around for a while I've found this Electrical junction box which was unused:

VideoCapture_20250210-224915.jpg

Then I printed "Happy Valentine's Day" and glued it on the box (missed an E there!):

20250206_145022.jpg

20250206_160548.jpg

Then I made the initial design on a piece of paper:

20250210_125021.mp4_snapshot_00.14_[2025.02.10_22.54.34].jpg

Since my ESP32 only has 17 output GPIO pins, I used 17 LEDs

Next Step I draw the LED places on the box and made holes by using a drill:

20250210_125307.mp4_snapshot_00.05_[2025.02.10_22.58.14].jpg
Note: Make sure the drill's head is the size of your LEDs

Choosing the write size Drill head makes things easy so without using glue or anything the LEDs will stay in their places:

20250210_125307.mp4_snapshot_05.37_[2025.02.10_23.02.17].jpg
20250210_130446.jpg

So the next step is to wire everything to the microcontroller and write the code.
It is very important to use resistors when you want to connect LEDs to your microcontrollers, these LEDs need 2.2V to 2.4V to work and if you don't use with a resistor it may burn the LED or your microcontroller's GPIO pin so a standard resistor to use with those is a 220ohm resistor:

20250210_163312.jpg
The color code is : Orange, Orange, Brown, Gold and size 1/4W

Here is how I wired everything on a breadboard:

20250210_163305.jpg

For better understanding and clarity I draw the schematics using Fritzing:

Untitle11d.png
(Shorter leg of each LED goes to the ground pin of ESP32 and longer leg of each LED first connected to one side of resistor and the other side of resistor will be connected to the related GPIO on the ESP32)
My ESP32 is a WROOM Dev Kit and it only has this GPIO output pins:
2, 4, 5, 12, 13, 14, 15, 18, 19, 21, 22, 23, 25, 26,27,32,33
GPIO 34 and 35 are input only and can't be used to power LEDs

So next I used extra wires to connect to LED legs to extend their distance from breadboard to reach their places on the box:

20250210_175619.jpg

20250210_182701.jpg
And here is a short video on my YouTube channel of the final result:

The Arduino code:

#define LED_COUNT 17
const int ledPins[LED_COUNT] = {2, 5, 15, 4, 18, 19, 21, 22, 23, 13, 12, 14, 27, 26, 25, 33, 32};
#define DELAY_TIME 100 // Delay between LED changes (milliseconds)

void setup() {
  // Initialize each LED pin as an output
  for (int i = 0; i < LED_COUNT; i++) {
    pinMode(ledPins[i], OUTPUT);
    digitalWrite(ledPins[i], LOW); // Initially turn off all LEDs
  }
}

void loop() {
  // Turn on all LEDs
  for (int i = 0; i < LED_COUNT; i++) {
    digitalWrite(ledPins[i], HIGH);
  }
  delay(DELAY_TIME); // Wait for a specified delay

  // Turn off all LEDs
  for (int i = 0; i < LED_COUNT; i++) {
    digitalWrite(ledPins[i], LOW);
  }
  delay(DELAY_TIME); // Wait for a specified delay
}

Outro

I hope you liked this simple tutorial, if you have any suggestions or questions please write down in the comment section.
I am also made a whole tutorial video of how to code on esp32 microcontrollers by using 3 different IDEs (Arduino IDE, ESP-IDF and PlatformIO) which soon I will upload on 3Speak.
Thanks for reading, Happy crafting!

Sort:  

I just wonder, do you sell your works. I think its worth and useful. Nice, God bless you 😊!

!LUV
!hiqvote

Thanks for the support, I believe in quality and I think for a product to be put out for sale it should have much better quality, cause you know if you value your customers or community, you will get better feedback, so for now I am working on the quality of my works and maybe in the future I make a useful product worthy for selling. Thanks 🙏.

@happyphoenix, the HiQ Smart Bot has recognized your request (1/2) and will start the voting trail.

In addition, @hadif66 gets !PIZZA from @hiq.redaktion.

Discord. And don't forget to vote HiQs fucking Witness! 😻For further questions, check out https://hiq-hive.com or join our