Jump to content
Electronics-Lab.com Community

Ashish Adhikari

Members
  • Posts

    26
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Ashish Adhikari

  1. Intro My 5-year old son asked me to create a Police Car like flashing light that he can put on top of his nerf-gun, while playing around with his mates. No worries mate, sounds like a plan to me. Bang, weekend sorted. In this tutorial I am going to create a Police Light themed LED Flashing circuit using the 555 timer IC. This circuit alternatively flashes between the Red and the Blue LED's while blinking each of them individually similar to the police strobe lights. To add some spice to this project you can also add a police siren to this circuit. However, I just wanted to keep it simple. Watch this video (https://youtu.be/4vDtWafMF0M) for detailed step by step instructions on how to build this circuit and for a complete instruction on how the circuit works. Disclaimer: This tutorial and the linked video are for educational purposes only. Components Required For this project we need: 6 x RED LEDs 6 x Blue LEDs 2 x 555 Timer ICs 2 x 1K Resistors 1 x 680K Resistor 1 x 100K Resistor 1 x 10uf Capacitor and 1 x 100nF Ceramic Capacitor (104) Depending upon the input voltage and the way you connect the LEDs (series or parallel) you will have to use different values of resistors in series with your LED’s. Please checkout http://ledcalc.com/ to calculate the resistor values based on your LED arrangements. How The Circuit Works Now, let's try to understand how this circuit works. This circuit has 2 parts. Part 1: Where the Blue and Red LEDs alternate and flash at a regular interval Part 2: Where a cluster of similar color LEDs flash like a strobe light In my previous tutorial "Adjustable Single/Dual LED Flasher Using 555 Timer IC", I showed you guys how to configure 555 timer IC to operate in an astable mode. In astable mode, the 555 timer IC acts as an oscillator (re-triggering itself) generating square waves [PWM Signals] from the output pin no. 3. Later I also showed you guys how to connect 2 LED’s in opposite polarity at the output pin Pin-3 so that they toggle ON and OFF at regular intervals of time. In this tutorial, I am using two copies of the previously shown "astable circuit" configured at different frequencies. The first 555 timer IC, uses a higher value capacitor and hence it takes more time to toggle the output. The second 555 timer IC uses a lower value capacitor and hence it toggles the output very fast. So, pretty much that's exactly what we want. The 1st 555 timer IC will help us in toggling between the LED clusters and the 2nd 555 timer IC will produce the strobe light effect. Now, lets connect the LED clusters to this circuit. The first LED cluster of the Red LED’s turns ON when the anode receives a positive voltage and the cathode is grounded. This happens when the output of first 555 timer IC is ON and at the same time the output of second 555 timer IC is OFF. Similarly, the second cluster of the Blue LED’s turn ON only when the output of the first 555 timer IC is OFF and the output of the second 555 timer IC is ON. Now, when the first 555 timer IC is ON it turns on the first cluster of Red LED’s and they blink at the speed at which the second 555 timer IC oscillates the output. Similarly when the first 555 timer IC turns OFF, the second cluster of Blue LED’s turns ON and blinks at the speed at which the second 555 timer IC oscillates the output. This cycle continues as long as there is power in the circuit creating a cool LED flashing effect similar to the flashing lights used on police cars. You can change the frequency of "toggling" between the successive LED groups by changing the higher value capacitor. Increasing its value will increase the time between the successive toggling between the two LED clusters and vice versa. Similarly, changing the value of the lower value capacitor will change the "blinking rate" of the LED clusters. Demo On Breadboard The Board So, this is how my board looks like in 2D and 3D. I have placed both ICs and all other electronics components to the middle of the board. To give the assembly a bit nicer look, I have placed the LED clusters on both sides of the board. Alright, now lets start soldering the components to the board. Soldering Since I care a lot about my ICs and microcontrollers I never solder them directly to the board. In case of ICs, I always try to use IC bases or if a base is not available I use female pin headers. After soldering the IC bases, I am soldering all the resistances to the board. Next, I am soldering the capacitors to the board followed by all the LEDs to the board. I am also soldering a female micro USB port to power this circuit board. Always check the polarity before soldering the socket to your board. To conclude the setup, I am installing the ICs to the IC bases. Final Demo So, this is how my final setup looks like. Do comment and let me know if there are any scopes of improvement. Thanks Thanks again for checking my post. I hope it helps you. If you want to support me subscribe to my YouTube Channel: https://www.youtube.com/user/tarantula3 Full Blog Post: Blog Post Video: Video Link Related Videos 1. Adjustable Single/Dual LED Flasher: Video Link 2. 555 Pulse Generator Module, How it Works: Video Link Gerber File: Download Schema: Download Resistor Value Calculator: Open Website Support My Work BTC: 1M1PdxVxSTPLoMK91XnvEPksVuAa4J4dDp LTC: MQFkVkWimYngMwp5SMuSbMP4ADStjysstm DOGE: DDe7Fws24zf7acZevoT8uERnmisiHwR5st ETH: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 BAT: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 LBC: bZ8ANEJFsd2MNFfpoxBhtFNPboh7PmD7M2 Thanks, ca again in my next tutorial.
  2. The 555 timer IC is an integrated circuit that is used in a variety of timer circuits, pulse generators and oscillator applications. The heart of the tutorial is the 555 timer IC that is wired as an astable multivibrator. In this tutorial, I'll first blink "an LED" using the positive pulse generated by a "DIY 555 Pulse Generator Module" (video: https://youtu.be/bMAnipPOjFo), followed by "two LEDs" alternating and flashing at a regular interval. The output frequency of pulses can be adjusted using a potentiometer. The circuit can be operated from any voltage between 5 to 15 volt DC. Watch this video for detailed step by step instructions on how to build this circuit and for a complete instruction on how the circuit works. Items Required For this tutorial we need: 2 x LEDs 1 x 555 Timer IC 1 x 10µF Capacitor 1 x 220Ω Resistor 1 x 1kΩ Resistor 1 x 10kΩ Resistor and/or 1 x 10kΩ Potentiometer Circuit Diagram The circuit is very simple. By connecting Pin 2 and 6 of the 555 timer IC, we put the IC in astable mode. In astable mode, the 555 timer IC acts as an oscillator (re-triggering itself) generating square waves [PWM Signals] from the output pin no. 3. By changing the values of R1, R2, and C1 we can change the frequency of the output pulses generated at pin number 3. Alright, let me explain this with the help of an animation. How The Circuit Works * When Pin 2 of the IC detects voltage LESS than 1/3rd of the supply voltage, it turns ON the output. * And, when Pin 6 detects voltage MORE than 2/3rds of the supply voltage, it turns OFF the output. * When the output is OFF, the Discharge Pin (Pin7) gets internally Grounded. This is how the trigger pin (Pin2) and the threshold pin (Pin6) of the 555 timer IC sense voltages and controls the output at Pin 3. * Capacitor C1 will be in a discharged state immediately when we firing up the circuit. * So, the voltage at Pin 2 will be 0v which is less than 1/3rds of the supply voltage, this will turn ON the output on Pin 3. * At the same time Pin 7 will internally disconnect from the GND and the Capacitor C1 will start changing via resistors R1 and R2. * Once the voltage across capacitor C1 crosses 2/3rds of the supply voltage, Pin 6 turns OFF the output. * At the same time Pin 7 will internally reconnect to the GND causing the capacitor C1 to discharge via resistor R1. * Once the voltage across the capacitor C1 falls below 1/3rd of the supply voltage, Pin 2 turns ON the output, and the above cycle keeps repeating itself. You can hook up a multimeter to the circuit to measure the charging and discharging of the capacitor. Since resistance R1 is involved in both charging and discharging of the Capacitor, increasing or decreasing its value will increase or decrease the duration of the OFF cycle and will decrease or increase the flashing rate of the LED, as the capacitor will take more time to charge and discharge. By replacing the capacitor with a higher or lower value, you can also get a longer or shorter flashing rate. By replacing the resistor R1 with a potentiometer the blinking rate of the LED can be dynamically adjusted. Now, for the Dual LED flashing effect we need to connect a second LED with opposite polarity to the Pin 3 of the IC. That's it, as easy as that. Calculations Now, lets calculate the output frequency and the duty cycle of the output waveform. In my setup I have resistance R1 = 1kΩ, R2 = 10kΩ and capacitor C = 10uF There are many online calculators to calculate this online. I will provide a link to one of the astable calculators in the description below: https://ohmslawcalculator.com/555-astable-calculator Lets first calculate the value of t1 or the 'capacitor charge “ON” time which is 0.693(R1 + R2 ) * C1. Putting the values together we get 76.23 milliseconds. Now, for capacitor discharge “OFF” time or t2 we need to multiply 0.693 to R2 and C1, which then gives us a value of 69.3 milliseconds. Next, the total periodic time T is equal to t1 + t2 which comes out to be 145.53 milliseconds. The output frequency, ƒ is therefore comes out to be to 6.871Hz. Which gives a duty cycle value of 52.38% If you want to have more control over the charging and discharging use a higher value for R2 (100K) and lower value for R1 (1K). That way you will have 99% control over the charging and discharging resistance in the circuit. The maximum output current of this IC is 200mA therefore to drive a higher current load of up to 1A we have to use a transistor like the BD135. The Board To make it easy for you guys, I have created this tiny little "555 Pulse Generator Module". After assembling the components, you just need to power this module by providing a voltage between 5v to 15v to get an oscillating output at the "Pulse" pin. So, this is how my board looks like in 2D and 3D. There are 16 breakout boards in this 100cm x 100cm assembly. You can download the gerber file from the link provided in the description below and order it from PCBWay. Soldering Before moving forward, let me quickly show you guys how to assemble the components to this custom made board. Let's start by soldering the IC Base to the board. Then let's solder the potentiometer to the board. After that lets solder the 1kΩ (R1) resistor to the board followed by the 10µF capacitor (C1) to the board. Once done, let's insert the 555 timer IC to the IC base. To conclude I have soldered 3 x Male pin headers to the board. Applications and Uses This circuit can be used to control the speed of DC motors and Stepper motors It can be used to control windscreen wiper motors to generate a to-and-fro motion It can be used as square wave signal generator It can be used as an adjustable pulse generator for MCUs In Strobe lights and SoS signaling circuits Telecommunications for encoding purposes In turning indicator circuits for all types of vehicles and bicycles To generate adjustable pulse (timing pulses) to control other circuits. As, in combination with the 4017 & 4026 ICs I have used this IC in few of my other projects and tutorials like the: DIY - Boba Fett Helmet With LED Chaser Circuit : https://youtu.be/vtO_GD0SS2s LED Chaser Circuits Using IC4017 and Arduino : https://youtu.be/F6V1AjESWbU DIY - LAN CABLE TESTER : https://youtu.be/PSK5Aa-byHA 555 Pulse Generator Module : https://youtu.be/bMAnipPOjFo Thanks Thanks again for checking my post. I hope it helps you. If you want to support me subscribe to my YouTube Channel: https://www.youtube.com/user/tarantula3 Full Blog Post: Blog Post Video: Video Link Related Videos 1. DIY - Boba Fett Helmet With LED Chaser Circuit : Video Link 2. LED Chaser Circuits Using IC4017 and Arduino : Video Link 3. DIY - LAN CABLE TESTER : Video Link 4. 555 Pulse Generator Module, How it Works : Video Link Gerber File: Download Calculator: Download Schema: Download Support My Work BTC: 1M1PdxVxSTPLoMK91XnvEPksVuAa4J4dDp LTC: MQFkVkWimYngMwp5SMuSbMP4ADStjysstm DOGE: DDe7Fws24zf7acZevoT8uERnmisiHwR5st ETH: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 BAT: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 LBC: bZ8ANEJFsd2MNFfpoxBhtFNPboh7PmD7M2 Thanks, ca again in my next tutorial.
  3. In my last tutorial I created a NodeMCU based Duino Coin Miner. It is an awesome little miner that sits on my desk and mines few cents a day. However, adding these miners to my home network choked my WiFi router. Home Appliances and Smart Devices connected to the router constantly started dropping off. To my understanding, most of the wireless routers and access points can support upto 250 devices connected at once. So, what's happening here? To clarify my doubts I called my ISP. The answer they gave was absolutely shocking. "ONLY 30 devices can successfully connect and exchange data via their router at any given time". Bloody hell!! So, to overcome this limitation I added another router to the network to scale up the load. But, I was not happy with this solution. So, I did a bit of research and found this "NRF24L01 RF Transceiver Module" which I can use to create a mesh of wirelessly connected microcontrollers. In this tutorial, I am going to show you guys how to use this transceiver module to add wireless communication between two or more Arduino boards. I will be using this module for many of my upcoming home automation projects. Bang Problem solved.. What is a NRF24L01 RF Transceiver Module? So far, I have always used WiFi for wireless communication between microcontrollers. While this is easy enough to do, it is not exactly suitable for battery operated nodes. WiFi modules consume a lot of current when transmitting data plus they also have a slight delay when initiating the transmission as the module has to first connect to the WiFi network. After getting crippled by the abilities of my wireless router, I found this cheap, very popular and widely used "RF Transceiver Module" which you can hook up to any microcontroller (MCU). This module is called a RF transceiver because a single module can work both as a transmitter and a receiver. The module operates at a frequency of 2.4GHz, which is one of the ISM band which means it is open to use in most of the countries around the World. Data transfer rate is between 250kbps to 2Mbps baud. Power consumption? This module is designed for ultra low power wireless applications. It has 2 power saving modes operating at 22uA Standby-I mode and 900nA in power down mode - which makes these modules suitable for battery operated nodes. The high air data rate combined with two power saving modes makes the nRF24L01 module very suitable for ultra low power designs. The power consumption of this module is just around 12 milliamps during transmission (TX) which is even lower than a single led. Operating voltage is between 1.9V to 3.6V. All other pins on this board are 5V tolerant making it easy to connect to an Arduino without using a logic level converter. It has an integrated (on chip) voltage regulator. The Range of this module as per its datasheet is 100m but it works up to 50 to 60 meters in real world conditions. The module has 125 independent RF channels giving the possibility to have a network of "125 independently working modems" in one place. Each channel can have up to "6 addresses or 6 data pipes" or in other words, each unit can communicate with up to 6 other units at the same time (1:6 star networks). The module is configured and operated through a Serial Peripheral Interface (SPI). It uses Enhanced ShockBurst™ for automatic packet assembly and timing, automatic acknowledgement and retransmission of packets. Enhanced ShockBurst™ enables the implementation of ultra low power, high performance communication with low cost host microcontrollers. The features enable significant improvements of power efficiency for bi-directional and uni-directional systems, without adding complexity on the host controller side. The module used in this video has an in-built PCB antenna making it compact. However, you can also buy a variant that supports an external antenna allowing much higher range of about 1000M in line of sight. nRF24L01 Pinout Now, lets have a look at the pinouts and specifications of the NRF24L01 module: GND: is the Ground Pin. It is placed inside a square for easy identification. VCC: supplies power to the module. Voltage can range from 1.9v to 3.9v. So, you can connect it directly to the 3.3V pin of our Arduino. Remember connecting it to a 5V pin will likely destroy your nRF24L01+ module! CE: (Chip Enable) is an active-HIGH pin. When selected the module will either transmit or receive, depending upon which mode it is currently in. CSN: (Chip Select Not) is an active-LOW pin and is normally kept HIGH. When this pin goes low, the module begins listening on its SPI port for data and processes it accordingly. SCK: (Serial Clock) it accepts clock pulses provided by the SPI bus Master. MOSI: (Master Out Slave In) It is SPI input to the module. It is used to receive data from the microcontroller. MISO: (Master In Slave Out) It is SPI output from the module. It is used to send data to the microcontroller. IRQ: It is the interrupt pin that alerts the master when new data is available to process. Setup and Schematic In order to get this working, we need two such NRF24L01 Modules and two Arduino Boards. For this tutorial I am going to use 2 Arduino Nanos. Just remember, we cannot use a breadboard with these modules because the pin spacing on these modules are not enough to place it in the middle and if you place it anywhere else, then you will end up shorting the pins. This means that you will either have to solder the wires directly to the modules or use some sort of jumper cables. The connection is exactly the same on both the transmitter and receiver end. Connect the GND pin to -ve and VCC pin to 3.3v pin of Arduino. The signals generated by these modules are very sensitive to power supply noises. So, adding a decoupling capacitor (anything from 10uF to 100uF) across the power supply line is always a very good idea. Then connect the CSN pin to D8, CE to D9, MOSI to D11, MISO to D12, and SCK to D13 pin of the Arduino. Since the nRF24L01+ module requires a lot of data transfer, it will give the best performance when connected to the hardware SPI pins on the microcontroller. Note that each Arduino board has different SPI pins that must be connected accordingly. Have a look at the table onscreen for quick understanding. Library Used For this tutorial I am going to use the "TMRh20/RF24" OSI Layer-2 driver for nRF24L01 on Arduino & Raspberry Pi/Linux Devices. You can download the library from the link provided in the description below: https://github.com/tmrh20/RF24/. Code 1 - Sending Text In my first example, I am going to send a character array from one module to the other. Using a split screen I am going to demonstrate this example. On my left is the Transmitter Code and on my right is the Receiver Code. Lets start by including the "SPI library" followed by the "RF modules library" downloaded from github in the code. Then we are creating a RF24 object by passing the CSN and CE as the two arguments to the radio() function. Next, we are creating an array of the addresses that the modules will use to communicate amongst themselves. The address can literally be anything, however, it has to be the "same" on both the transmitter and the receiver modules. This is how the RF modules know who they have to communicate with. In the setup section we first initialize the radio object. Then, using the radio.openWritingPipe() function we set the address of the transmitter which we will use to send data to the receiver module. On the receiving end we use the radio.openReadingPipe() function with the same address to read the data from the data pipe. Next we set the power amplifier level. Since the modules in this demo are sitting next to each other, I am using the "Minimum Level". Next, in the transmitter code we need to tell the module to stop listening using the radio.stopListening() function. This sets the module as a transmitter. On the receiver module we need to start listening using the radio.startListening() function. This sets the module as a receiver. After that, in the loop() section of the transmitter, we send an array of characters using the radio.write() function and on the receiver end we read the array using the radio.read() function and display it on the serial monitor every second. Code 1: Download Code 2 - Lighting Up LEDs In the second example, I am going to light up two LEDs on the receiver-end based on whichever button is pressed on the transmitter-end. To achieve this I have added 2 LEDs on the receiver end and 2 Push Button switches on the transmitter end. When Button B1 is pressed the transmitter sends "B1" using the radio.write() function and when Button B2 is pressed the transmitter sends "B2" using the radio.write() function to the receiver module. The "switch statement" in the receiver code then lights up the corresponding LED based on whichever button was pressed on the transmitter end. Code 2: Download Code 3 - Same Node Acting as TX and RX [Bidirectional Communication) In my 3rd example I will show you guys how a single node can act as both transmitter and receiver. Just remember you "cannot" send and receive data at the same time. Using the "stopListening()" and "startListening()" functions we will toggle between sending and receiving of data on the data pipes. What's different here from the previous code is that we are creating two pipes or addresses for the bi-directional communication. const byte addresses[][10] = {"ADDRESS01", "ADDRESS02"}; In the setup section we need to define both pipes in a way that the sending address of the 1st module is the receiving address of the 2nd module and vice versa the receiving address of the 1st module needs to be the sending address of the 2nd module. Now in the loop section of the 1st Arduino, we use the radio.stopListening() function to turn the node into a transmitter and send the data using the radio.write() function. On the receiver end we use the radio.startListening() function to read the incoming data. While there is incoming data (radio.available()) we read it using the radio.read() function. Then we add a bit of delay to the code. After that, we set the 1st Arduino to receiving mode using the radio.startListening() function and the 2nd Arduino to transmitting mode using the radio.stopListening() function. The data is then displayed on screen using the Serial Monitor. Code 3 : Download Code 4 - Multiple Nodes [Mesh - Multiceiver Network] The nRF24L01+ has a feature called Multiceiver. It is an abbreviation for Multiple Transmitter Single Receiver. In my 4th example, I am going to show you guys how to connect multiple transmitters to a single receiver. In a Multiceiver network each RF channel is logically divided into 6 parallel data channels or the data pipes. Each data pipe has its own unique data pipe address. Only one data pipe can receive a packet at a time. So basically, the primary receiver in the middle is collecting data from 6 different transmitting nodes simultaneously. The primary receiver can stop listening any time and start acting like a transmitter. This way you can create a mesh of network where each node can act as a repeater. There is a different library "RF24Mesh" you need to use to create this mesh network. Since I don't have that many modules handy at this moment, I am unable to show you guys the working bit of it. However, I will create a 2nd tutorial dedicated just to the mesh network, so stay tuned. Using Sleep Mode There is a way to conserve battery by sending the module to sleep mode. Please read through the "pingpair_sleepy" example for more details, I have provided the link in the description below. Factor Effecting The Transmission These modules work very well when the transmitter and receiver are close to each other. If the distance is too big you may lose the communication. The signals generated by these modules are very sensitive to power supply noises. Depending upon the amount of noise, the communication rate may vary. Setting the maximum output power can also improve the communication range. If there’s an obstacle in the line of sight you may see multiple dropouts. Reducing the data rate can significantly improve the performance. A speed of 250kbps is more than enough for most of our projects. Using an external antenna can also significantly improve the transmission rate. Another potential source of noise for RF circuits is WiFi. Especially when someone's network is set on the same channel. Since WiFi mostly uses the lower frequency channels, it is recommended to use the highest 25 channels for your nRF24L01+ modules. Thanks Thanks again for checking my post. I hope it helps you. If you want to support me subscribe to my YouTube Channel: https://www.youtube.com/user/tarantula3 Blog Posts: Visit Website Video references: Visit Website DataSheet: Download Schema Schema - Sending Text: Download Schema - Lighting Up LEDs: Download Code Code 1 - Sending Text: Download Code 2 - Lighting Up LEDs: Download Code 3 - Bidirectional Communication: Download Libraries Used TMRh20/RF24 : Visit Website TMRh20/RF24 : Download RF24Mesh : Visit Website pingpair_sleepy : Visit Website Support My Work BTC: 1M1PdxVxSTPLoMK91XnvEPksVuAa4J4dDp LTC: MQFkVkWimYngMwp5SMuSbMP4ADStjysstm DOGE: DDe7Fws24zf7acZevoT8uERnmisiHwR5st ETH: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 BAT: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 LBC: bZ8ANEJFsd2MNFfpoxBhtFNPboh7PmD7M2 Thanks, ca again in my next tutorial.
  4. Crypto Mining using microcontrollers, wait what!!! Are you serious? How? Believe it or not, the rig you see onscreen actually mines a crypto currency called DUINO-Coin (ᕲ) or DUCO. The total cost of this rig is only $35. Now, if you believe me! then, grab yourself a cup of coffee, sit back and watch this video and start your journey into cryptocurrency with DUINO-Coin! What is DUINO-Coin? DUINO-Coin (ᕲ) was founded in 2019 and is a for-fun project. This project was developed by a team of young developers that focuses on energy efficient mining. It's mostly, but not only, dedicated to people who are just starting out in the crypto world and it doesn't require any expensive hardware. DUCO is a transparent, open-source, centralized, eco-friendly coin that focuses on mining with low-powered devices like Arduino. DUCO tries to achieve a reward system using "Kolka" a name derived from Coca Cola making the low-powered devices like Arduino earn almost the same or even "more" than a powerful device like CPUs or GPUs. It also prevents people from building huge mining farms. It causes each additional miner to earn a bit less from the previous one. DUCO is "centralized" and has an "infinite supply" and hence you can mine this coin forever. You can Mine DUCO using: Android smartphone Computer's CPU Arduino (or compatible AVR) Raspberry Pi, Orange Pi or Banana Pi ESP8266/ESP32 (or compatible boards) Internet browser on PC or smart-TVs Arduinos using ESP8266 as a host Arduinos using Raspberry Pi as a host Centralization: Making Arduino and other low powered devices not only profitable, but just possible would be impossible to maintain if the coin was decentralized. Hence, DuCo is a centralized coin with it's own chain. It is however possible to wrap (convert) DUCOs to wDUCO, bscDUCO, celoDUCO or maticDUCO to store them in decentralized form on another coin's chain. To start your journey, have a look at the getting started with Duino-Coin webpage. Then, create a wallet to store your coins. Next, download the miner binaries for the device you are going to mine the coin. If you are super tech savvy, then have a look at the coins whitepapers. The link is in the description below. In my setup, I am mining DUCO using NodeMCU. Schema The setup is very simple. In my setup I have added an extra LED to give my board a bit of Si-Fi look. Mining with ESP boards allows you to mine headlessly - you don't need to have them connected to a computer as they have their own Wi-Fi capabilities to connect to the server. The Board Now, lets have a look at my board. You can hookup, 5 x NodeMCUs to this board. Each NodeMCU has its own flashing LED. The board can be powered using just 5v using a USB cable. So, this is how the NodeMCU DUCO Miner blade looks like in 3D. Soldering Lets start by soldering all the small components to the board. I first soldered all the LEDs and the resistances to the board. Since I care a lot about my Sensors and Microcontrollers, I am not going to solder them directly to the board. Instead I am soldering 'female pin headers' to the board which will house the NodeMCUs in them. Finally, I soldered a USB cable to power the blade. I extracted this cable from a broken iPhone's charger. Code I downloaded the code from the DUINO-coins website. The current version is 3.0. I downloaded the windows version and then added my code block to make the blue LED flash on my blade. In the code, you just need to edit few line in the top section to add your Wi-Fi details and the name of the NodeMCU. If you're using an ESP8266 board, you can set the clock speed (Tools > CPU frequency) to 160 MHz to achieve better hash-rates. Then, just go ahead and upload the code one by one to all your NodeMCU's. Before adding the NodeMCU to your rig, it is a good idea to check it using the Arduino Serial Monitor (Tools > Serial Monitor), set the baud rate to 500000 baud and see how's the ESP is doing. If everything is correct, you should see messages saying that a share was accepted. If it all works fine, your ESP will mine as long as it has power and internet connection. Demo So, this is how my final setup looks like. To be very frank, the setup actually looks like having a small Christmas tree on your table, ha ha. Hash-Rate Mining DUCO at this stage is not very profitable. However, I just wanted to share the hash-rate table with you guys. Remember, Kolka will play an essential role, as you keep on adding devices to your rig. So, the hash-rate you will get may not be same as what you see on-screen. Claiming Via Faucets You can also claim DUCO via web-faucets. I have scene many faucets coming in and completely disappearing, so the links provided in the video may not be valid when you try to access them. The first one in list is the "faucet.duinocoin.com". You can claim 1 DUCO from this website by solving a captcha to start your journey. Remember you can only claim once from this website. The next one is the "furim.xyz". Again, you just need to solve a captcha to earn some DUCO. The 3rd one in list is "duco-faucet.pcgeek.pl" same as the other two, you can claim some DUCO every 15 minutes by solving a captcha on this website. Exchanging DUCO After mining some DUINO-Coins, you may want to exchange them to some other currency. To exchange your coins, simply visit the website and select the currency you want to exchange. At the moment of writing this tutorial, DUCO Exchange supports XMG, BCH, TRX, BYND and LKE coins. After deciding which coin you want exchanged, simply fill in the exchange form and wait for the exchange to happen (it may take up to 72 hours). You'll shortly receive an e-mail confirming the process and describing any further steps if needed. Other exchanges: Other exchanges supporting DUINO-Coin are Node-S, PancakeSwap, SunSwap, and SushiSwap. Thanks Thanks again for checking my post. I hope it helps you. If you want to support me subscribe to my YouTube Channel: https://www.youtube.com/user/tarantula3 Blog Posts: Visit Website Video references: Visit Website Code Release 3.0 Original: Download Release 3.0 Modified: Download Resource Pages Getting started: Visit Website Create Wallet: Visit Website App list: Visit Website Exchange: Visit Website White Paper: Visit Website Dashboards Dashboard-1: Visit Website Dashboard-2: Visit Website Dashboard-3: Visit Website Facets List Faucet-1: Visit Website Faucet-2: Visit Website Faucet-3: Visit Website Discussion Discord: Visit Website Reddit : Visit Website Support My Work: BTC: 1M1PdxVxSTPLoMK91XnvEPksVuAa4J4dDp LTC: MQFkVkWimYngMwp5SMuSbMP4ADStjysstm DOGE: DDe7Fws24zf7acZevoT8uERnmisiHwR5st ETH: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 BAT: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 LBC: bZ8ANEJFsd2MNFfpoxBhtFNPboh7PmD7M2 Thanks, ca again in my next tutorial.
  5. In my last tutorial I created a Weather Station using Arduino and NodeMCU using DHT11 or DHT22 temperature and humidity sensor and displayed it using an OLED Display. In this tutorial, I am going create a Peg-Box using the same board but with a little bit of twist. In this setup, I am going to send the Temperature and Humidity readings to my Raspberry Pi based home server and store it in a MySQL database. The data can then be viewed using PHP and Google Charts, on a Mobile Phone or a PC connected to the home network. Circuit Diagram The setup is very simple. The temperature and humidity sensor sends the collected data to the NodeMCU on pin D3. NodeMCU then sends the data over WiFi to the Raspberry Pi, which is then saved in the MySQL database. The Yellow LED, which is the status indicator flashes every second and is connected to D6 pin of the NodeMCU. The Blue LED connected to pin D5, lights up when NodeMCU sends the temperature and humidity readings to the database. If you are planning to install this box somewhere inside the house, then you can also add an OLED display and display the readings on it. The Board So, this is how my board looks like in 2d and 3d. There are 3 breakout boards in this 100cm x 100cm assembly. Each board can be used with either Arduino or NodeMCU and DHT11 or DHT22 sensor or sensor module. Temperature and humidity readings can be collected using either a DHT11 or DHT22 Module or by using one of these sensors with a 10K resistor. The bottom section of the board is for the OLED display. The attached gerber is bit different from what you see on screen. I made some modifications in the final version and moved the sensors a bit far from the microcontrollers. Component Assembly Lets start by soldering the female pin-headers to the board. The pin-headers will house the NodeMCU in it. Next, lets soldered few more pin-headers for the LEDs, DHT11 sensor and the OLED display. Before installing the circuit in the peg-box, lets hook up the OLED Display and make sure everything works as expected. Boom, nailed it. The Code The code starts by including all the libraries and by defining all the constants and variables that will be used throughout the program. Then there are two functions SendIamAlive() and SendTemperatureAndHumidity() which sends heartbeat and the data read from the temperature sensor to the database server. The ReadDHTSensor() function reads the data from the DHT11 or DHT22 sensor. In the setup section we first setup the WiFi and then send a SendIamAlive() message to the server advising that it is back up and running. Then in the loop section the microcontroller send a heartbeat every minute using the SendIamAlive() function and if the time elapses it sends the humidity and temperature data using the SendTemperatureAndHumidity() function. The White LED flashes every seconds and the Blue LED turns on when the device sends the temperature and humidity data to the database server. MySQL So,the data sent by the NodeMCU over WiFi is saved in the MySQL database hosted on a RaspberryPi 4. Here you can see, the microcontroller sends the data every 30 minutes (you can change the frequency) which is then saved in the MySQL database. The data saved on the Pi's MySQL database can then be used to generate various different types of graphs either by using google charts or any other 3rd party application. It totally depends on you how you want to present it. 3D Design Now, lets look at the design of the peg-box. Using freely available pallet planks, I designed the body of the box. The pallet planks I am using are 160cm x 9cm x 2cm (length, width and thickness). So, the rest of the measurements will be based on that. The top bit of the peg-box will house the microcontroller and the sensors in it. Putting it on the top prevents the electronics from adverse climatic conditions. The back bit will stick to wall and hence we don't need to cover it up. You can either put the pegs straight in the front bin or throw it to the top bit, from where it will slide down to the front bin. The sliding design with an opening in the front will prevent rainwater from accumulating inside the bin. This mechanism will keep the bin dry throughout the year. Woodworking Using 2 hammers I am dismantling the pallet. My aim is to reuse all the nails used in building this pallet so that, I can use them in building my project. After that, I sanded the pallet planks to give them a nice and smooth texture. Then using a chop-saw or a hand-saw I extracted all the pieces of wood required for building this project. As mentioned earlier, my pallet plank are 9cm wide and hence, all the onscreen measurements are based on that. Final Assembly Using wood-glue I am joining all pallet planks used in making the box. I got a bit too excited and accidentally deleted one of my recordings. So, I am using 3D animation to show you guys how I joined the two sides of the box. I used a plywood board to created the base of the bin. I glued few cylindrical wooden sticks on the roof of the box. To be very frank these sticks changed the entire outlook of the peg-box. Coloring Since my aim is to install the peg-box outside the house, I have to make sure that I apply multiple coats of paint on the box to avoid the pallet wood from rotting. I applied 3 coats of paint on the entire setup and insulated all the holes that I found using wood putty. So, this is how it looks like. The electronics bit will stay hidden under the roof of the box. Ha ha, Don't worry, I will obviously insulate them and make them weather-proof before installing them on the wall. Installation Now the next thing you need to do is to find a spot where you want to install this unit. I am installing this near my clothesline, however you may want to install it in your pantry or behind a door or something like that. It totally depends on how much space you have and where you want to install it. I am using metal frame hangers to hang this on the wall. Place the unit against the wall, and using a pencil mark the points where you want to drilling the holes. Now, using a hammer drill, drill the holes in the wall. Then, put the wall plugs in the wall and then use a screw driver to install the screws. Alright so, that's it. This unit is now all set to hold all my pegs in it. Demo So, this how my final setup looks like. Do comment and let me know if there are any scopes of improvement. Thanks Thanks again for checking my post. I hope it helps you. If you want to support me subscribe to my YouTube Channel: https://www.youtube.com/user/tarantula3 Blog Posts: 1. Peg Box 2. DHT11 & DHT22 3. OLED Tutorial Video references: 1. Peg Box 2. DHT11 & DHT22 3. OLED Tutorial Resources: Gerber Schema 3D Model Code: Code (Arduino + PHP + MySQL DB) Code_With_OLED_Arduino Code_With_OLED_NodeMCU Code_With_PHP_NodeMCU Libraries: DHTStable.h SSD1306.h Adafruit display library Adafruit GFX library Support My Work: BTC: 1M1PdxVxSTPLoMK91XnvEPksVuAa4J4dDp LTC: MQFkVkWimYngMwp5SMuSbMP4ADStjysstm DOGE: DDe7Fws24zf7acZevoT8uERnmisiHwR5st ETH: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 BAT: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 LBC: bZ8ANEJFsd2MNFfpoxBhtFNPboh7PmD7M2 Thanks, ca again in my next tutorial.
  6. It’s almost Valentine’s Day. This year, instead of giving her a rose bouquet, I wanted to express my love by gifting her an electronic breathing heart. This is yet another "cheap DIY kit" intended for educational purpose. There are a few variations of the breathing LED projects with similar setup, however the one with blue LEDs attracted me a lot. #valentinesDayGift #ArduinoGiftIdea #ElectronicsValentinesDay Video: https://youtu.be/cq6fEPNtxn4 Unpacking The Kit Same as any other cheap DIY kit, this one came in a zip lock bag without any instructions. However, the component values and polarities are vey well denoted on the board, so I did not had Google at all. Inside the zip lock bag you will find: 1 LM358 IC 22 LEDs 6 Resistors 1 47uf Capacitor 1 Push ButtonSwitch 1 Adjustable Tri-Pot and 1 SS8050 NPN Transistor There is no IC base present in this package. However, I would highly recommended using one for your IC. How This Circuit Works To get the fading effect we need to generate a series of triangular waves. Because of the triangular waves, the LED starts glowing slowly and then slowly dims off and the cycle continues. This setup is done using the LM358 IC. LM358 is a dual operational amplifier (Op-Amp) IC, integrated with two op-amps powered by a common power supply. Pins 1, 2, and 3 are one op-amp channel, and pins 5, 6, and 7 are the 2nd op-amp channel. As the capacitor charges and discharges the state of the PIN 3 switches from high to low and based on that the PIN 2 of the op-amp obtains the desire output. If you want to know more about this IC, please check out my "Tutorial No 21 : DIY - IR Module" : https://youtu.be/_M8FQIPi1qk. So, basically the op-amp here is used for voltage level detection. In this circuit, we are applying a voltage on positive pin (PIN-3) and the voltage to be detected is applied at negative pin (PIN-2). The transistor acts as a signal amplifier. You will need this if you are attaching a cluster of LEDs however for just 1 LED you can simply remove it. Soldering Soldering the components to the board was pretty straightforward and relatively trouble free. I just had to pay a bit of attention to the directions of the components when soldering them to the board. I started the project by soldering the IC base to the board followed by the capacitor, transistor, pot and the push button switch. Next, I soldered all the resistors to the board. After that, I soldered all the LEDs to the board, due to the repetitive nature of the LED installation the installation may slightly be tedious. However once you finish soldering all the components, I bet you will feel proud of yourself. Not to mention, the zip lock bag contains few spare LEDs, umm.. a thoughtful addition. Quick Test So this is how it looks like. The effect is a blue heart that increases and decreases in brightness in a cyclical fashion. The speed/depth can be adjusted using the onboard pot. To be very frank, the diffused LEDs make it quite appealing and less glary when you look at it. Cutting The Heart Now that I have all the electronics bit sorted, it was time for me to add the accessories to it. Something just clicked in my mind and I went ahead and cut a "heart shape" from a piece of pallet. I will later stick the circuit board to this heart shaped pallet plank. Sanding the plank well, and adding a bit of olive oil gave the heart shape a shiny, nice and smooth texture. Items Required For the rest of the project I am using a dog made of clay and some broken pieces of artificial plants. It totally depends on you, what you want to add to give your project a super sexy look. Preparing the base Now to house all the bits and pieces that I gathered so far, I need to create a base. For that, I am cutting a 6" x 3.5" pallet plank. All the bits and pieces will be glued to this pallet plank. Assembling The Heart I drilled a hole in the middle of the wooden heart. Through this hole I will pass the wire that will power the circuit board. The power supply to this board is between 4v-6v DC. Any USB interface, or three ordinary dry cells can be used to power this board. The supply voltage to the red LED version is slightly lower than that all other colored LEDs. A 4v power supply can power the Red version; however, other colors need voltage between 4v 5v 6v. Putting All The Bits Together All right, so now its just a matter of gluing all the bits and pieces one by one to the base pallet plank. Demo When you are young and restless, Valentines Day plays a significant role in your life. However, if you are deeply in love with someone who you are going to spend your rest of the life with, everyday becomes Valentines Day for you. Thanks Thanks again for checking my post. I hope it helps you. If you want to support me subscribe to my YouTube Channel: https://www.youtube.com/user/tarantula3 Blog Posts: https://diyfactory007.blogspot.com/2022/02/Valentine-2022.html Video: https://youtu.be/cq6fEPNtxn4 LED Fader: https://youtu.be/IIUsdICycOw DIY - IR Module : https://youtu.be/_M8FQIPi1qk Cos.TV: https://cos.tv/videos/play/34112835833860096 Odysee: https://odysee.com/@Arduino:7/yt5s.com-Cute-Little-Valentine's-Day-Gift:3 Support My Work: BTC: 1M1PdxVxSTPLoMK91XnvEPksVuAa4J4dDp LTC: MQFkVkWimYngMwp5SMuSbMP4ADStjysstm DOGE: DDe7Fws24zf7acZevoT8uERnmisiHwR5st ETH: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 BAT: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 LBC: bZ8ANEJFsd2MNFfpoxBhtFNPboh7PmD7M2 Thanks, ca again in my next tutorial.
  7. Couple of months ago, I bought a "Raspberry Pi Pico" to get some hands-on experience of it and to create some amazing projects using it. But since then, it has just been sitting on my desk, collecting dust. Today after a very long wait, I finally have decided to create a short video tutorial to show you guys how to get started with the Raspberry Pi Pico. Topics Covered In this tutorial, I am going to discuss: 1. What is a Raspberry Pi Pico? 2. The technical specifications of the board 3. How to program Pico using C/C++ and MicroPython a. Programming Raspberry Pi Pico using "Arduino IDE" i. Preparing the Arduino IDE ii. Loading the Blink Example iii. Demo b. Programming Raspberry Pi Pico using "Tonny Python IDE" i. Installing MicroPython on Pico ii. Installing Tonny Python IDE iii. Loading the Blink Example iv. Demo 4. Difference between Raspberry Pi Pico and Arduino 5. Advantages and Disadvantages of this board What is Raspberry Pi Pico? Raspberry Pi Pico is a low-cost microcontroller. It can be used to control other electronic modules and sensors same as any other microcontroller. Pico is not a Linux single board computer, rather it is a microcontroller like Arduino. Since, its a microcontroller it doesn't come with all the overheads that a computer brings and hence consumes much less current. actually it is more like Arduino than Raspberry Pi. Pico is not a rival of Raspberry Pi Zero, it actually can work in conjunction with the regular Pi's. Pico is breadboard friendly and has 40 GPIO pins operating at 3.3v (20 on each side). It has a Dual-Core ARM Cortex M0+ processor. Pico's brain - the RP2040 microcontroller chip is designed by Raspberry Pi in United Kingdom. It can be powered either via the micro USB port, or via the VSYS GPIO pin by providing voltage between the range of 1.8V to 5.5V. Technical Specifications of Pico Raspberry Pi Pico is absolutely different from all other Raspberry Pi models. Pico is one of the first microcontrollers to use the RP2040 "Pi Silicon" processor. It is a custom "System on Chip" (SoC) developed by the Raspberry Pi team in UK which features a dual core Arm Cortex M0+ processor running at 133 MHz, 264KB of SRAM and 2MB of flash memory for storing files on it. Specifications: - Microcontroller: RP2040 designed by Raspberry Pi in the UK - Processor: Dual-Core Arm Cortex-M0+ processor, flexible clock running up to 133 MHz - Input power: 1.8 - 5.5 V DC - Operating temperature: -20°C to +85°C - Dimensions: 51.0 x 21.0 mm - Onboard Sensors: Temperature Sensor - Memory: 264KB of on-chip internal SRAM and can support up to 16MB of off-chip Flash 2MB on-board QSPI Flash (Adafruit's Feather RP2040, features 16MB of storage) - GPIO: It has 40 GPIO through-hole pins also with edge castellation - 26 × multi-function 3.3V GPIO pins, which includes 3 analogue inputs (The Analog inputs is something other Raspberry Pi's lack. They use variable voltages to connect to devices like a potentiometers, joystick or a LDR) - 2 × SPI, 2 × I2C, 2 × UART, 3 × 12-bit ADC, 16 × controllable PWM channels - 8 × Programmable I/O (PIO) state machines for custom peripheral support that can offload many kinds of timing-critical processes from the CPU - Other Features: - 1 × Contains 1 × USB 1.1 controller and PHY, with host and device support - Accurate clock and timer on-chip - Low-Power sleep and dormant modes - Accelerated integer and floating-point libraries on-chip - Works with Windows, Mac, Linux machines and Raspberry Pi Computers - Provides drag-and-drop programming using mass storage over USB The one biggest disadvantage of the Raspberry Pi Pico is that there is no WiFi or Bluetooth on it. ESP32 and ESP8266 which you can buy for similar price comes with WiFi and Bluetooth (ESP32). Surely we can add wireless connectivity via external components, however that would require a little bit more knowledge and experience to get it working. Since Pico is not a computer, we need to write our codes on a different machine using an external application and then "flash" the code onto the microcontroller over USB. Pinout Diagram: Here is the top view of the pinouts on the Raspberry Pi Pico. The pin-labels are on the bottom side of the board. How to program Pico using C/C++ and MicroPython Pi Foundation officially supports MicroPython and C/C++, however high-level programming language like CircuitPython (A fork of MicroPython created by Adafruit), and Drag and Drop Python Editor like Pico Piper which adds further enhancements and can be used to program the Pico boards. Programming Raspberry Pi Pico using Arduino IDE Python and C/C++ are both great for programming Picos. However, being able to program a Pico just like an Arduino would help us to integrate the Pico into the Arduino ecosystem. One of the best reasons to do this is because of the availability of libraries to integration of modules, sensors, and other complex stuff without having to write the entire code from scratch. i. Preparing the Arduino IDE To start, let go to Tools > Boards > Boards Manager and search for "Pico", select "Arduino Mbed OS RP2040 Boards" and hit the install button. Connect the micro USB cable to the Pico and then press and hold the "BOOTSEL" button before plugging the USB cable into the computer. Release BOOTSEL once the drive RPI-RP2 appears on your computer. Now, go to Tools > Port and you will now be able to see the number of the COM Port. ii. Loading the Blink Example Go to Files > Examples > Basics > Blink and click on Upload, this will load the code to the Pico board. iii. Demo After the IDE finished uploading the code, you will see the Pico's onboard LED blinking. You can now use your Pico like an Arduino and program it using the Arduino IDE. Programming Raspberry Pi Pico using Tonny Python IDE You can program your Pico using MicroPython by connecting it to a computer via USB and then dragging and dropping files to it. i. Installing MicroPython on Pico Installation of MicroPython on Pico requires a "UF2" file to be copied onto it. A UF2 file is a "binary data file" which contains a program that can be transferred from a PC to a microcontroller, such as an Arduino or Pico circuit board. To load MicroPython on Pico: 1. Download "MicroPython UF2 file" from the link provided in the description below. 2. Connect the micro USB cable to the Pico and then press and hold the "BOOTSEL" button before plugging the USB cable into the computer. Release BOOTSEL once the drive RPI-RP2 appears on your computer. 3. Drag and drop the UF2 file onto the RPI-RP2 volume. 4. Your Pico will reboot. That's it, you are now running MicroPython on your Pico. ii. Installing Tonny Python IDE To write code and save files to Pico we are going to use the "Thonny Python IDE". Thonny comes with built-in Python 3.7, so just one simple installer is what you need to learn programming. To get started: 1. Download and install "Thonny" free from the Thonny website for your version of OS. The website's link is in the description below. Note: If you are running "Raspberry Pi OS" then Thonny is already installed on it, but may need to update it to the latest version sudo apt update && sudo apt upgrade -y 2. Connect the Raspberry Pi Pico to your computer. Then, in Thonny go to Tools > Options and click on the "Interpreter" tab. From the interpreter dropdown list select "MicroPython (Raspberry Pi Pico)". The port dropdown menu can be left to "automatically detect the Pico". Click "OK" to close. 3. A Python Shell called "REPL" (Read, Eval, Print, Loop) will popup to show that the Pico is connected and working. iii. Loading the Blink Example 1. Click in the main editor pane of Thonny and enter the following code to toggle the onboard LED. from machine import Pin, Timer led = Pin(25, Pin.OUT) timer = Timer() def blink(timer): led.toggle() timer.init(freq=2.5, mode=Timer.PERIODIC, callback=blink) 2. Click the "Run" button to execute the code. 3. Thonny will ask whether you want to save the file on "This computer" or the "MicroPython device". Choose "MicroPython device". Enter "blink.py" as the file name. Make sure you enter ".py" as the file extension so that Thonny recognizes it as a Python file. iv. Demo You should now see the onboard LED switching between on and off until you click the Stop button. Difference between Raspberry Pi Pico and Arduino * Before Raspberry Pi Pico, Raspberry Pi has always been know for their single board computers. However, in 2021 Raspberry Pi Foundation stepped a few steps forward and launched the Raspberry Pi Pico giving a head-to-head challenge to Arduino and all other board based microcontrollers. * Arduino was first introduced in 2005 and since then Millions of Arduino Units have been sold in the market. Compared to that, the response Pico received after its initial launch in 2021 is absolutely mind-blowing. * Both units are made for automating applications that don’t involve human intervention. * Pico can be used alone or in combination with Arduino for Automation and AI purposes. * Both modules are different in terms of power consumption, value, functionality, and price. * Pico boards come unsoldered however Arduino comes pre-soldered or unsoldered. * Pico module supports MicroPython and C/C++, while Arduino codes are written in C/C++ using Arduino.IDE. So which one to go for… Pico or Arduino? Advantages and Disadvantages Now lets have a look at the Pros and Cons of this microcontroller board. Advantages: * Raspberry Pi Pico is cheap, very small, and easy to use microcontroller * Pico is a dual core device coupled to a high-performance bus matrix, which means its both cores can give you the full performance concurrently * Pico consumes very low power * Pico is a breadboard friendly * Pico can be programmed using C/C++ and MicroPython * Pico can be programmed using Arduino IDE * Pico has 26 × multi-function 3.3V GPIO pins (23 Digital + 3 Analogue) * Pico comes with 8 x Programmable IO (PIO) and 2 x Analog Inputs * Pico boots quickly and doesn’t require a safe shutdown Disadvantages: * Pico completely lacks WiFi and Bluetooth without any add-ons * It lacks the GPIO markings on the top side of the board * The board comes unsoldered so you will have to solder the header pins or surface mount it to use it in your project * GPIO pins are 3.3V, which could be seen as a disadvantage, however devises designed for 5V can still be used with 3V via a voltage divider or a logic level converter. * Pico still uses micro-USB port. While many other microcontrollers have moved to USB-C, Pico is still coming with the micro-USB port If you have a Windows, Apple, Linux or even a Raspberry Pi, then you are already well in your way to program the small, cute, and gorgeous Raspberry Pi Pico in your next project. I bet, there must be a lot of project ideas going in your mind, so get your supplies and start coding. And, what are you waiting for??? Thanks Thanks again for checking my post. I hope it helps you. If you want to support me subscribe to my YouTube Channel: https://www.youtube.com/user/tarantula3 Blog Posts: https://diyfactory007.blogspot.com/2022/01/getting-started-with-raspberry-pi-pico.html Video: https://youtu.be/vO_2XWJDF70 Other Resources: RP2040 Datasheet : https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf Hardware design with RP2040 : https://datasheets.raspberrypi.com/rp2040/hardware-design-with-rp2040.pdf Raspberry Pi Pico Datasheet : https://datasheets.raspberrypi.com/pico/pico-datasheet.pdf Getting started with Raspberry Pi Pico : https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf MicroPython UF2 : https://micropython.org/download/rp2-pico/rp2-pico-latest.uf2 Thonny website : https://thonny.org/ Piper Make: https://make.playpiper.com/ CircuitPython 7.1.0: https://circuitpython.org/board/raspberry_pi_pico/ Support My Work: BTC: 1M1PdxVxSTPLoMK91XnvEPksVuAa4J4dDp LTC: MQFkVkWimYngMwp5SMuSbMP4ADStjysstm DOGE: DDe7Fws24zf7acZevoT8uERnmisiHwR5st ETH: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 BAT: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 LBC: bZ8ANEJFsd2MNFfpoxBhtFNPboh7PmD7M2 Thanks, ca again in my next tutorial.
  8. I love mining and I truly believe that blockchain and digital currencies will one day change the world. Cryptocurrency has played a significant role in my life and has made me a morning person, ha ha. Miners require 24 x 7 access to the Internet. Recently, I went on a short business trip and my router for some stupid reason stopped working. I lost complete access to my home network and my miners. When I returned from my trip, my only aim was to fix this issue by creating an "Internet Hardware Watchdog" that reboots the router whenever something silly happens to it. Note: If you do any work with "mains power" such as 120v or 240v AC power wiring, you should always use proper equipment and safety gears and determine whether you have adequate skill and experience or consult a Licensed Electrician. This project is not intended for use by children. The Logic Let me first explain the logic to you. In a nutshell, in this setup I am going to ping "www.google.com" and as soon as the ping drops I will reboot the router. To achieve this, the NoduMCU first connects to the WiFi network and then pings 8.8.8.8 (www.google.com). If it receives a successful ping, one out of the 3 blue LED patterns is displayed. If the ping fails, 5 more retries are given before rebooting the router. The reason I am NOT rebooting the router straightaway is to avoid false positive ping fail responses. However, once the "fail_count" counter becomes 5, NodeMCU turns off the router by pulling the armature of the relay module. The armature of the relay is held for 15 seconds before releasing it so that the router is properly power cycled. Once the armature is released, the system waits for a minute before sending the next ping request. This gives enough time to the router to successfully perform its POST activities. The above steps are then endlessly repeated in the loop section of the code. Components Required For this project we need: NodeMCU Stepdown Converter Relay Module 2 x Red LEDs 3 x Blue LEDs 100Ω Resistor Power Plug and a Power Socket Schematic Now, let's put the components together exactly the way I have shown in the schematic diagram. Be very careful while handling AC Main Power sockets and cables. The Stepdown Converter powers the NodeMCU and the Relay Module. LEDs are connected to the Digital pins of the microcontroller. The relay acts as a switch and switches on or off the router based on the ping response. Please make sure you check the pins of your relay module before hooking it up to the circuit. The Board So, this is how my board looks like in 2D and 3D. I basically have created a replica of the NodeMCU Prototyping Board which you can buy from AliExpress for about $4 to $6. Components Assembly Lets start by soldering the NodeMCU to the board. Since I care a lot about my Sensors and Microcontrollers, I am not going to solder them directly to the board. Instead I am soldering 'female pin headers' to the board which will house all the sensors and the microcontrollers in them. I initially thought of soldering the LEDs directly on the board however something clicked in my mind and I went ahead and soldered them on a separate perfboard and then soldered the perfboard to the NodeMCU development board. Well, this was totally unnecessary. Once the LEDs were in place, my next step was to solder the step-down-converter and the relay-module to the board. If you want to know how I created this relay module, please check out my tutorial no. 19 DIY Relay Module : https://www.youtube.com/watch?v=3n69b4sdDjk the video and the blog post links are in the description below. Next, I made a hole in the transparent box and glued the power socket into it. Well I created a bit of mess while gluing the socket and accidentally glued the box on to my dining table, silly me. I also drilled a hole at the back of this box, for the cable that will connect to the AC Main power supply. Pretty much that's it. Once again, I would like to warn you guys: If you do any work with the "main power" such as 110v or 240v AC, you should always use proper equipment and safety gears and determine whether you have adequate skill and experience or consult a Licensed Electrician. This project is not intended for use by children. To conclude the setup, I added a small skull inside the acrylic box. This skull has been sitting on my desk just collecting dust for over a year, ha ha. The Code Now, let's have a look at the code. You can download the code and other resources from the links provided in the description below. To Run the attached code you need to download and install the "ESP8266Ping" library. You can either download it from GitHub or from the link provided in the description below. Unzip and copy the archive to the Arduino's Library Folder and change the board type to ESP8266 in the Arduino IDE and select NodeMCU. The code starts by including all the libraries and variables on top. Then in the setup() section I have defined all the pin modes and have made a connection to the WiFi router. In the loop() section I am performing a ping test and based on the test result I am either blinking the blue LEDs or power cycling the router. Thanks Thanks again for checking my post. I hope it helps you. If you want to support me subscribe to my YouTube Channel: https://www.youtube.com/user/tarantula3 Blog Posts: Internet Hardware WatchDog : https://diy-projects4u.blogspot.com/2021/12/internet-hardware-watchdog.html DIY Relay Module : http://diy-projects4u.blogspot.com/2020/08/diy-relay-module.html Video: Internet Hardware WatchDog : DIY Relay Module : https://www.youtube.com/watch?v=3n69b4sdDjk Other Resources: Code: https://drive.google.com/file/d/1HyTUMUBDK0neO854XMl3dyy5ceoeTImw/view?usp=sharing ESP8266Ping Library : https://github.com/dancol90/ESP8266Ping.git ESP8266Ping Library : https://drive.google.com/file/d/1uFfY5wW7-oWRNjP_XaBj2IM189M1n1FK/view?usp=sharing Schema: https://drive.google.com/file/d/1gn2ZhMp5Uz4YDv5GjxgIq1rtzh-21Rwe/view?usp=sharing Gerber File: https://drive.google.com/file/d/1l0bszJ0AV7S9s-y9jTWGcw9MrWayVJxZ/view?usp=sharing Flowchart: https://drive.google.com/file/d/1CL3g0nT1IZfdL8MZqN_PB-mKC9k_JfWH/view?usp=sharing Support My Work: BTC: 1M1PdxVxSTPLoMK91XnvEPksVuAa4J4dDp LTC: MQFkVkWimYngMwp5SMuSbMP4ADStjysstm DOGE: DDe7Fws24zf7acZevoT8uERnmisiHwR5st ETH: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 BAT: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 LBC: bZ8ANEJFsd2MNFfpoxBhtFNPboh7PmD7M2 Thanks, ca again in my next tutorial.
  9. If you have ever programmed a NodeMCU, then I bet you know the pain you have to go through while connecting sensors to NodeMCU on a breadboard. I looked for various solution on the web and found "NodeMCU Development Boards" for around $6 to $7. Well, I wasn't ready to spend that much for a simple projects. So, I went ahead and designed a replica of those boards, which, 10 of them I got fabricated from PCBWay for just $5. PCB Design Let me first show you the design of the board. I have placed the NodeMCU in the middle of the board. On the right hand side are the extensions of all the digital pins. And on the left hand side are the extensions of the left hand side pins. Starting from left to right I have the VIN and the -VE pin to power up the NodeMCU at the bottom left hand side of the board. NodeMCU has an inbuilt LDO voltage regulator which keep the voltage level at 3.3v so there is no need for an additional voltage regulator. Just above that, is a series of GND pins. On top of that is a series of +5v and GND pins, followed by a series of 3.3v and GND pins. I have also added a series of 3v3 and GND pins on the top right hand side of the board. Then there is a reset button and a set of TX and RX pins for serial communication. On the same breakout board I have also added an Arduino Nano's Development Board. Since, I had a fair bit of real-estate left on my board, I created a generic PCB out of the left over space. PCB Assembly Lets start by soldering the male and the female pin headers to the board. It really doesn't matter, what order you solder the components to the board. The only think to remember is that, do not solder a component that blocks another one. As you can see, I am soldering both male and female pin headers side by side on the board so that sensors with either male or female pin header can be hooked up to the board, making it more generic and expandable. So, this is how the final setup looks like. Please comment and let me know if there is any scope of improvement, thanks. Thanks Thanks again for checking my post. I hope it helps you. If you want to support me subscribe to my YouTube Channel: https://www.youtube.com/user/tarantula3 Blog Posts: https://diyfactory007.blogspot.com/2021/11/nodemcu-development-board.html YouTube: https://youtu.be/y2m2nh7wHaY Odysee : https://odysee.com/@Arduino:7/DIY---NodeMCU-Development-Board:1 cos.tv : https://cos.tv/videos/play/32048547001832448 Schema : https://drive.google.com/file/d/1XRR2sNZ5t4NhLFla9X3DyjaPAujrjeGY/view?usp=sharing Support My Work: BTC: 1M1PdxVxSTPLoMK91XnvEPksVuAa4J4dDp LTC: MQFkVkWimYngMwp5SMuSbMP4ADStjysstm DOGE: DDe7Fws24zf7acZevoT8uERnmisiHwR5st ETH: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 BAT: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 LBC: bZ8ANEJFsd2MNFfpoxBhtFNPboh7PmD7M2 Thanks, ca again in my next tutorial.
  10. Created a touchless Covid Free Electronic Dice using Arduino to play some board games with my son. My new project is an amazing way of giving our younger generation the taste of board games while staying COVID free. Total cost: AU$12 Time taken: 4hrs Components Required For this project we need: 1 x Push Button Switch 1 x Arduino Nano R3 (or ESP8266) 1 x 8x8 Led Matrix with MAX7219 IC 1 x Step Up Power Module [MT3608] 1 x IR Sensor 1 x AA Battery Holder and Batteries and Some Connecting Cables Circuit Diagram Using a Step Up Power Module connected to 2 x AA batteries I am powering up the Arduino Nano. In my logic, I am using an IR Module to send interrupts, which changes the face of the dice which is then displayed using a 8x8 LED Matrix. If you want to know more about the DIY IR module please check out my "Tutorial No. 21: DIY - IR Module". Link is in the description below. Video: https://youtu.be/_M8FQIPi1qk Blog : http://diy-projects4u.blogspot.com/2020/10/diy-ir-module.html If you want to change the face of the dice by shaking it, you can use a tilt sensor to generate the interrupts. If you want to store the results in a database, you can use a ESP8266 board and send the result over WiFi and store it in a database. The possibilities are endless, however, I just want to keep my circuit simple. The Code The code is very simple. Lets start by including the "LedControll.h" library. I have included the link to the library in the description below. Next, lets define all the pins that we are going to use in our code. After that, you will find few functions that work in combination to generate the dice faces and the dice animation. In the setup() section, we are setting up the pinMode of the IR Sensor and initializing the display. We are also showing the initial animation where in my case, number 6 flies from right-to-left and fills up the led display. In the loop() section I am reading the IR sensor to check if someone has moved their hand over the sensor module. If a motion is detected, then a random number between 1 and 6 is generated, and based on that the face of the dice changes using ShowDicePic() function. Housing Design Now lets create the body of the dice. From a broken piece of chipboard, I extracted the 6 sides of the dice. Next, using a double-sided tape I attached the AA battery holder to the bottom of the dice. Then, I soldered the step-up converter to the AA battery holder. The step-up boost converter has to be adjusted to approximately 5V before installation by twisting the variable resistance in it. I made a hole on one of the sides for the push button switch, and then glued the push button switch to it. I hot-glued the 8x8 LED matrix to the top section of the dice. 8x8 LED matrix with MAX7219 driver IC, is a very cheap, easy to code and it takes up very little space in your project. The top section also has the IR transmitter and receiver LEDs. Pretty much I hot glued them all and then attached them to a Arduino Nano. Then, I made 4 holes on the bottom plate and attached the all the sides to it. Lets do a quick test before finalizing the project. Looks promising, isn't it? Cool, so this is how my final setup looks like. I covered the LED Matrix with a translucent black sheet. Let me know what you guys think of this project. If you have any suggestions or advises please feel free to drop a comment below. Thanks Thanks again for checking my post. I hope it helps you. If you want to support me subscribe to my YouTube Channel: https://www.youtube.com/user/tarantula3 Blog Posts: 1. Arduino Dice : https://diy-projects4u.blogspot.com/2021/10/arduino-dice.html 2. DIY IR Module: http://diy-projects4u.blogspot.com/2020/10/diy-ir-module.html Video references: 1. Arduino Dice : https://www.youtube.com/watch?v=a4CnaDDR2x0 2. DIY IR Module: https://www.youtube.com/watch?v=_M8FQIPi1qk Schema: https://drive.google.com/file/d/168eiuHINb_5dGh9wBQ1qDsTv3bXY39Hj/view?usp=sharing Code : https://drive.google.com/file/d/1jLRFUFD3P037GIfAIZJU2GpHcbZOxgpc/view?usp=sharing LedControll.h : https://drive.google.com/file/d/1U5SFjC8Q6bB_X8ZQeJ6Ifq7ID5iecZ0K/view?usp=sharing Support My Work: BTC: 1M1PdxVxSTPLoMK91XnvEPksVuAa4J4dDp LTC: MQFkVkWimYngMwp5SMuSbMP4ADStjysstm DOGE: DDe7Fws24zf7acZevoT8uERnmisiHwR5st ETH: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 BAT: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 LBC: bZ8ANEJFsd2MNFfpoxBhtFNPboh7PmD7M2 Thanks, ca again in my next tutorial.
  11. In this tutorial I am going to show you guys how to make an Arduino or NodeMCU based Weather Station using DHT11 or DHT22 temperature and humidity sensor and display it using an OLED Display. DHT11 vs DHT22 The DHT11 and DHT22 are both low-cost very basic and slow temperature and humidity sensors which can be used for basic data logging. Despite being slower, they are very stable and consumes low power and provides relatively high measurement accuracy. The single-bus digital signal is output through a built-in ADC which is easy to read using any microcontroller. Single bus interface saves the I/O resources of any microcontroller board. The operating voltage is between 3.3V to 5V and the sampling period for DHT11 is 1Hz or one reading every second and for DHT22 is 0.5Hz or one reading every two seconds. Hence, you can not query them more than once every second or two. The DHT sensors are made of two parts, a capacitive humidity sensor and a Negative Temperature Coefficient or NTC temperature sensor (or thermistor). The NTC temperature sensor is actually a variable resistor whose resistance decreases with increase in the temperature. For measuring humidity, two electrodes with a moisture holding substrate between them is used. When the humidity changes, the conductivity of the substrate changes or in other words the resistance between these electrodes changes. This change in resistance is measured and processed and is sent to the microcontroller. A very basic chip inside the sensor does the analog to digital conversion and spits out a digital signal which is read using a microcontroller. Here is a comparison chart of the two sensors. Looking at this it is very clear that DHT22 outshines the DHT11 in every aspect. However, if accuracy is your concern, and you are ready to pay a bit higher price, go for DHT22. Otherwise, DHT11 should be good enough for you. OLED Display OLED or organic light-emitting diode is a light-emitting diode (LED) in which the emissive electroluminescent layer is a film of organic compound (millions of small LED lights) that emits light in response to an electric current. OLEDs are used to create digital displays in devices such as television screens, computer monitors, portable systems such as mobile phones, hand-held game consoles and PDAs. An OLED display works without a backlight because it emits visible light. There are many types of OLED displays available in the market based on their: Sizes Color Brands Protocol SPI (Serial Peripheral Interface) or I2C Passive-matrix (PMOLED) or active-matrix (AMOLED) control scheme To know more about OLED Display and to know how to connect multiple OLED Displays using TCA9548 multiplexer check out my tutorial number 7 OLED Display with Arduino and NodeMCU link is in the description below: https://www.youtube.com/watch?v=_e_0HJY0uIo Lets have a closer at these two displays. At the back of these displays there are heaps of SMD capacitors and resistors soldered on-board; but, since its an I2C device we only care about these 2 pins (SCL and SDA) The display connects to Arduino using only four wires – two for power (VCC and GND) and two for data (serial clock SCL and serial data SDA), making the wiring very simple. The data connection is I2C (I²C, IIC or Inter-Integrated Circuit) and this interface is also called TWI (Two Wire Interface). The on-board pins can be in different order, so always triple check before hooking it up to your project. Operating voltage is between 3v to 5v but, it is best to use the guidance from the manufacturer's datasheet. Sometimes we need to use 2 displays in our projects. So, how can we achieve this? The trick is to have a configurable address on your display. This unit has a configurable address between 0x78 and 0x7A. Just by unsoldering the 0Ohm resistor from one side and hoking it up to the other side or just by putting a global solder we can change the address. In picture these displays look very big. But, practically speaking they are tiny. They are made of 128 x 32/64 individual OLED pixels and do not require any back-light. Just have a look at this and see how small it is. Even though they are small they can be very useful in any electronic projects. This is how an OLED Display is connected to either Arduino or NodeMCU. Setup Using Arduino The setup using either Arduino or NodeMCU is very simple. We just need to connect the OLED to the I2C Pins and the Temperature and Humidity sensor to any one of the Digital pins. In this setup I have connected the OLED to A5 and A4 and the Sensor to D8. Now, lets look at the code. Lets start by including the DHT and OLED libraries. Then, in the setup section we initialize the display and then in the loop section we loop through every 2 seconds and read the sensor and display the result on the OLED display. Here is a quick demo using Arduino. Setup Using NodeMCU Same as the previous setup, the OLED display connects to the NodeMCU using D2 and D1 pins and the Sensor connects to the D3 pin. The code starts by including the DHT and OLED libraries. Then, in the setup section we initialize the display and then in the loop section we loop through every 2 seconds and read the sensor and display the result on the OLED display. So, this is how the actual setup looks like. The Board So, this is how my board looks like in 2d and 3d. There are 3 breakout boards in this 100cm x 100cm assembly. Each board can be used with either Arduino or NodeMCU and DHT11 or DHT22 sensor or sensor module. The Board can be used with either NodeMCU or Arduino Nano. Temperature and humidity readings can be collected using either a DHT11 or DHT22 Module or by using one of these sensors with a 10K resistor. The bottom section of the board is for the OLED display. The attached gerber is bit different from what you see on screen. I made some modifications in the final version and moved the sensors a bit far from the microcontrollers. Soldering Since I care a lot about my Sensors and Microcontrollers I am not soldering them directly to the board. Instead I am soldering, female pin headers to the board which will house all the sensors and microcontrollers. Just for the sake of this video I am soldering female pin headers on both sides for Arduino and NodeMCU. However, In your setup you will need either Arduino or NodeMCU. Final Demo Lets first test this with an Arduino. Now, lets test this setup using a NodeMCU board. Looks perfect, I am going to use this board in my next project where I will be sending Temperature and Humidity readings to my Raspberry Pi based home server where I will be storing it in a MySQL database, so stay tuned.... Thanks Thanks again for checking my post. I hope it helps you. If you want to support me subscribe to my YouTube Channel: https://www.youtube.com/user/tarantula3 Blog Posts: 1. DHT11 & DHT22: https://diyfactory007.blogspot.com/2021/09/temperature-and-humidity-monitor-using.html 2. OLED Tutorial: https://diyfactory007.blogspot.com/2018/07/oled-i2c-display-arduinonodemcu-tutorial.html Video references: 1. DHT11 & DHT22: https://youtu.be/w5tBtHsl7b4 2. OLED Tutorial: https://www.youtube.com/watch?v=_e_0HJY0uIo Gerber: https://drive.google.com/file/d/1H9noO2ppm0SM8HcJg1NWE2uTUJKw9SXH/view?usp=sharing Schema: https://drive.google.com/file/d/1tWCxXBw3vzssVm6FtZDRI8ZIPCtmXp1t/view?usp=sharing Code: Code_With_OLED_Arduino : https://drive.google.com/file/d/1EEdhPuUiy8xWSD_s41iYAccTz8w-QF9C/view?usp=sharing Code_With_OLED_NodeMCU : https://drive.google.com/file/d/1WFtdyu90gAqxhJq-Pur7w8fvXuuM85lt/view?usp=sharing Code_With_PHP_NodeMCU : https://drive.google.com/file/d/1bT08x-h39NS1LdkCCH2F3ySG3hrht9U4/view?usp=sharing Code_With_PHP_OLED_NodeMCU: https://drive.google.com/file/d/1ji5TEvLbhe3GJiDgQRowDws5PdZZXqf9/view?usp=sharing Libraries: "DHTStable.h" : https://github.com/RobTillaart/DHTstable "SSD1306.h" : https://github.com/squix78/esp8266-oled-ssd1306 Adafruit display library: https://github.com/adafruit/Adafruit_SSD1306 Adafruit GFX library: https://github.com/adafruit/Adafruit-GFX-Library Support My Work: BTC: 1M1PdxVxSTPLoMK91XnvEPksVuAa4J4dDp LTC: MQFkVkWimYngMwp5SMuSbMP4ADStjysstm DOGE: DDe7Fws24zf7acZevoT8uERnmisiHwR5st ETH: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 BAT: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 LBC: bZ8ANEJFsd2MNFfpoxBhtFNPboh7PmD7M2 Thanks, ca again in my next tutorial.
  12. The 555 timer IC is an integrated circuit that is used in a variety of timer circuits, pulse generators and oscillator applications. The heart of the module is the 555 timer IC that is wired as an astable multivibrator, generating pulses from about 4Hz to 1.3Khz. This circuit can be used in any project, that requires positive pulses. To demonstrate the operation, a LED is used at the output of the IC to show the visual indication of the output pulses. The output frequency of pulses can be adjusted using a potentiometer. The circuit can be operated from any voltage between 5 to 15 volt DC. Items Required For this project we need: 1 x 555 Timer IC 1 x 10µF Capacitor 1 x 1kΩ Resistance and a 1 x 10kΩ Potentiometer Circuit Diagram The circuit is very simple. By connecting pin 2 and 6 we put the 555 timer in astable mode. Astable mode causes the 555 timer to re-trigger itself, producing a stream of pulses [PWM Signals] as long as its hooked up to a power supply. Pin number 3 is the output pin. By changing the values of R1, R2, and C3 we can change the frequency of output pulses generated at pin number 3. How It Works The working voltage of the circuit is between 5V~15V DC. As previously discussed 555 timer generates PWM signals when set up in an astable mode by connecting the pin 2 and 6 together. During each cycle capacitor C3 charges up through both R1 and R2 resistors but discharges itself only through resistor R2 as the other side of R2 is connected to the discharge terminal pin 7. Changing the values of R1, R2, and C3 will change the frequency of output pulses, or different duty cycle of the square wave coming out of pin 3. By changing the value of R2 we can change the duration of the OFF cycle. In this setup the ON time depends on the resistor R1, the left side of the pot and the capacitor C3, while the OFF time depends on the capacitor C3 and the right side of the pot. Now, lets calculate the output frequency and the duty cycle of the output waveform. In my setup I have resistance R1 = 1kΩ, R2 = 10kΩ and capacitor C = 10uF There are many online calculators to calculate this online. I will provide a link to one of the astable calculators in the description below: https://ohmslawcalculator.com/555-astable-calculator Lets first calculate the value of t1 or the 'capacitor charge “ON” time which is 0.693(R1 + R2 ) * C3. Putting the values together we get 76.23 milliseconds. Now, for capacitor discharge “OFF” time or t2 we need to multiply 0.693 to R2 and C3, which then gives us a value of 69.3 milliseconds. Next, the total periodic time T is equal to t1 + t2 which comes out to be 145.53 milliseconds. The output frequency, ƒ is therefore comes out to be to 6.871Hz. Which gives a duty cycle value of 52.38% If you want to have more control over the charging and discharging use a higher value for R2 (100K) and lower value for R1 (1K). That way you will have 99% control over the charging and discharging resistance in the circuit. The maximum output current of this IC is 200mA therefore to drive a higher current load of up to 1A we have to use a transistor like the BD135. For driving a much higher current than 1A you can use other high current transistors like TIP31, 2N3055, etc. with a good heatsink. TIP122 can only go up to about 1.5 amps without a heatsink, however it can go up to 5 amps with a good heatsink. IRLB8743 FET is good to around 20 amps without a heatsink. The Board So this is how my board looks like. There are 16 breakout boards in this 100cm x 100cm assembly. You can download the gerber file from the link below and order it from PCBWay. Soldering Lets start by soldering the IC Base to the board. Then lets solder the potentiometer to the board. After that lets solder the R1 resistor to the board followed by the C3 capacitor to the circuit board. Once done lets place the 555 timer IC to the IC base. To conclude I have soldered 3 x Male pin headers to the board. Demo So, this is the final appearance of the board. I am adjusting the output frequency of pulses using the 10K potentiometer. Applications and Uses This circuit can be used to control the speed of DC motors As square wave signal generator Adjustable pulse generator for MCU Driving stepper motor Telecommunications for encoding purposes Generate adjustable pulse to control other circuits I have used this in few of my projects like: DIY - Boba Fett Helmet With LED Chaser Circuit : https://youtu.be/vtO_GD0SS2s LED Chaser Circuits Using IC4017 and Arduino : https://youtu.be/F6V1AjESWbU DIY - LAN CABLE TESTER : https://youtu.be/PSK5Aa-byHA Thanks Thanks again for checking my post. I hope it helps you. If you want to support me subscribe to my YouTube Channel: https://www.youtube.com/user/tarantula3 Full Blog Post: https://diy-projects4u.blogspot.com/2021/07/555-pulse-generator-module-how-it-works.html Video: https://youtu.be/bMAnipPOjFo Related Videos: 1. DIY - Boba Fett Helmet With LED Chaser Circuit : https://youtu.be/vtO_GD0SS2s 2. LED Chaser Circuits Using IC4017 and Arduino : https://youtu.be/F6V1AjESWbU 3. DIY - LAN CABLE TESTER : https://youtu.be/PSK5Aa-byHA Gerber File: https://drive.google.com/file/d/1YE5vznhAcQx2cmlXouRhn2yxZB3Lb2RK/view?usp=sharing Calculator: https://drive.google.com/file/d/17dTw22opXIw8WI4-knUZu4rr6k-6zlxV/view?usp=sharing Schema: https://drive.google.com/file/d/1K635sLu-J3UQzEibjANlfm8ywCgy4tJ0/view?usp=sharing Support My Work BTC: 1M1PdxVxSTPLoMK91XnvEPksVuAa4J4dDp LTC: MQFkVkWimYngMwp5SMuSbMP4ADStjysstm DOGE: DDe7Fws24zf7acZevoT8uERnmisiHwR5st ETH: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 BAT: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 LBC: bZ8ANEJFsd2MNFfpoxBhtFNPboh7PmD7M2 Thanks, ca again in my next tutorial.
  13. Whether you prefer to unwind the evening with a good book, play games on your phone, or wanna have some cozy time with your partner, the right bedside lighting can make a lot of difference. In this project, I am going to make a touchless multipurpose bedside lamp, which will also include a digital clock, two power-ports and a USB charger. Sponsors This video is sponsored by PCBWay. PCBway: only $5 for 10 pcbs from https://www.pcbway.com/?from=CZcouple Woodwork Lets start the project by sanding a pallet planks to give it a nice and smooth texture. Then, lets drill 3 holes for the top and the 2 sides of the night lamp. After drilling the holes lets extract the sides from the plank using a chop-saw or a hand-saw. My pallet plank is 9.5cm wide and the lamp will be square in shape. So, rest of the measurements are based on that. Assembly Once all the sides were ready its was time for me to join them all together. First of all I am getting the 2 x sides ready by gluing the power sockets into the holes. Next, I drilled 2x more holes for the IR sensor. If you want to know more about IR sensors please check out my "Tutorial No 21 : DIY - IR Module : https://www.youtube.com/watch?v=_M8FQIPi1qk" Next, one by one using wood glue I am joining the 2 x sides to the top of the lamp. At first I thought of using nails to join the sides, but soon I realized that by all means it was a very bad idea. Before gluing the 2nd side I connected the two power ports together using a copper wire. Alright now, Lets look at the electronics bit. Electronics For the electronics bit we need: 1 x IR Sensor 5 x Colored LEDs 5 x 220Ω Resistors 1 x 10uf Capacitor 5 x 2N2222 NPN Transistor 1 x 4017 IC 4017 is a Decade Counter IC, it can count from 0 to 10. When a clock signal is received on Pin-14 the output turns to high one by one in a sequence. The signal from the IR-Sensor clocks the 4017 decade counter. Whenever a pulse is received at the clock input of IC, the counter increments the count and activates the corresponding output PIN. In our project we only need to count upto 5 so the 6th output from Pin-5 will be given to the Reset Pin-15. Sending a high signal to Pin-15 will reset the counter and it will skip counting the rest of the numbers and will start from the beginning. A capacitor is added to filter out too frequent detection of object by the IR sensor. To add a cluster of LEDs to the circuit, we just need to feed the output from the IC to a transistor and the cluster can then be connect to the transistor. Similar to this setup. Top - Soldering Components So, now lets start putting the components together. Lets solder the IC base followed by the 5 x NPN Transistors. Then, lets solder the 220Ω Resistors and the 10uf Capacitor to the board. I also added few pin headers to the board, 3 for the IR Sensor and 2 for the 5v power supply. The transistors are connected to the ribbon of wire which then connects to the cluster of LEDs that will slide under the top section. Before putting the circuit into production lets do a quick test. Bang, nailed it.. Front - Clock For the front bit I am using a 4-Bits DIY Electronic Digital Clock which I bought from AliExpress for just AU$2.40. If you want to know more about this clock please checkout my "Tutorial No 12 : DIY - Wooden Clock : https://youtu.be/Av0riH_ncsE " I moved the 2 push button switches from the board to the front panel of this lamp. My initial plan was to cover this entire setup with timber veneer sheet. However, I could not find one that was thin enough to not completely hide the 7-segment display. So, I ended up putting a black plastic film over the 7-segment display. Back - USB Port The back bit will host the USB ports and will also have a hole for the AC power chord. Lets have a look at this USB port. When I am holding a USB port upside down the left most pin is the -ve pin and the rightmost is the +ve pin. The middle two are the data pins which I am not going to use in this project. I used a Rubber Grommet to safeguard the power chord's hole. To power the electronics bit I am using a USB charger. I glued the USB charger to the back bit of the lamp. I soldered the power supply cable to the USB charger and then hot-glued to protect it from touching the other electrical and electronic components. Then I glued the back and the front plates of the lamp to the wooden frame. I soldered all the electronics components to the USB charger. Bottom - Power Supply The bottom bit will hold the AC Power Cables. Since I don't want the AC cables to float around and cause short circuits inside the lamp, I screwed them to the base of the lamp. Painting I painted the lamp a little bit to give it a modern look. Next, I superglued the black plastic film and painted its edges to match the whole setup. To finalize the setup, I added a bit of hot-glue to the bottom of the lamp. These glue drops will stop this lamp from scratching my bedside table top. Demo Covid has taught us many things, it has changed our life. This project was an attempt to make things touchless. Hope you guys enjoyed it. Thanks Thanks again for checking my post. I hope it helps you. If you want to support me subscribe to my YouTube Channel: https://www.youtube.com/user/tarantula3 Full Blog Post: https://diyfactory007.blogspot.com/2021/05/touchless-multifunctional-bedside-lamp.html Video: https://youtu.be/r1r9jIgtcEk Links: Tutorial No 21 : DIY - IR Module :: https://www.youtube.com/watch?v=_M8FQIPi1qk Tutorial No 12 : DIY - Wooden Clock :: https://youtu.be/Av0riH_ncsE Music: Nocturne - Asher Fulero Music: Simple - Patrick Patrikios Support Me: BTC: 1M1PdxVxSTPLoMK91XnvEPksVuAa4J4dDp LTC: MQFkVkWimYngMwp5SMuSbMP4ADStjysstm DOGE: DDe7Fws24zf7acZevoT8uERnmisiHwR5st ETH: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 BAT: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 LBC: bZ8ANEJFsd2MNFfpoxBhtFNPboh7PmD7M2 Thanks, ca again in my next tutorial.
  14. Have an awesome project in mind using some LEDs. In that project I will be using some LED Fading Effect and few LED Chaser Circuits. But before jumping onto that, I thought I should create a short tutorial and show you guys how to fade a LED with or without an Arduino automatically or manually using a potentiometer. Video: https://youtu.be/IIUsdICycOw Sponsors This video is sponsored by PCBWay. PCBway: only $5 for 10 pcbs from https://www.pcbway.com/?from=CZcouple PCBWay specialize in manufacturing of very high quality, low-volume, colored PCBs at a very budgetary price. In addition to the standard PCBs, you can also order Advanced PCBs, Aluminum PCBs, FPC/Rigid-flex PCBs. They also provide PCB assembly and other related service which can meet your needs to the greatest extent. The ordering process from PCBWay is very easy. Once I had my design ready, I just had to upload the gerber file to the PCBWay's website and select the type, color and any other customization that I want and then just send it for fabrication. For my project, I choose the black color. PCBWay ships from china to most of the countries of the world within 3 to 7 business days. Talking about the quality, its absolutely mind-blowing. Without Arduino Lets first create the fader circuit without an Arduino. The base of this circuit is an operational amplifier IC named LM358. In this circuit, initially, the LED slowly glows with increasing brightness & after reaching its maximum brightness, the LED slowly dims its brightness and the process continues. Automatic Fading Components Required For the Non-Arduino bit we need: 1 x LM358 IC 1 x BC547 Transistor 1 x 0.47µF Capacitor 2 x 4.7KΩ Resistors 1 x 22KΩ Resistor 1 x 10KΩ Resistor 1 x 4.7MΩ Resistor 1 x 220Ω Resistor 1 x LED and a 9V Battery How This Circuit Works To get the fading effect we need to generate a series of triangular waves. Because of the triangular waves, the LED starts glowing slowly and then slowly dims off and the cycle continues. This setup is done using the LM358 IC. LM358 is a dual operational amplifier (Op-Amp) IC, integrated with two op-amps powered by a common power supply. Pins 1, 2, and 3 are one op-amp channel, and pins 5, 6, and 7 are the 2nd op-amp channel. As the capacitor charges and discharges the state of the PIN 3 switches from high to low and based on that the PIN 2 of the op-amp obtains the desire output. If you want to know more about this IC, please check out my "Tutorial No 21 : DIY - IR Module" : https://youtu.be/_M8FQIPi1qk. So, basically the op-amp here is used for voltage level detection. In this circuit, we are applying a voltage on positive pin (PIN-3) and the voltage to be detected is applied at negative pin (PIN-2). The transistor acts as a signal amplifier. You will need this if you are attaching a cluster of LEDs however for just 1 LED you can simply remove it. The Board So, this is how my board looks like in 2D and 3D. There are 15 breakout-boards in this 100cm x 100cm assembly. Component Assembly Now, lets solder all the components to the board. Lets first solder all the resistances to the board. Then lets solder the transistor followed by the capacitor to the board. After that lets solder the LED and the female pin header. To conclude the setup, lets solder the IC base and then install the IC into it. Demo So, this is how it looks like. Good thing about LEDs is that they can be easily controlled as compared to the traditional light bulbs. Which means you can easily change their intensity based on your need. Just by making a slight modification to this circuit you can change the brightness of a LED Lamp when someone walks in or out of a room. Manual Fading Using PWM Now, if you want to get the same dimming effect but want to manually control the intensity, you will have to find a way to modulate the pulse sent to the LED or group of LEDs using a potentiometer. I am going to do this by generating PWM Signals. What is PWM? Pulse Width Modulation, or PWM, is a technique for getting analog results with digital means. PWM value varies from 0 to 255. The bigger the value of PWM, the brighter the LED is and vice versa. - If PWM = 0, it is same as GND, so the LED will be OFF - If PWM = 255, it is same as VCC, so the LED will be fully ON To get varying analog values, you change, or modulate, that pulse-width. If you repeat this on-off pattern fast enough with an LED, the result is as if the signal is a steady voltage between 0 and 5v controlling the brightness of the LED. In this setup, we are going to use the 555 Timer IC in Astable mode (A free-running multivibrator that has NO stable states but switches continuously between two states this action produces a train of square wave pulses at a fixed known frequency) to generate the PWM Signals. 555 Timer IC will vary the voltage delivered to the LEDs to achieve the Dimming effect of the LED. Components Required For this setup we need: 1 x 555 Timer IC 1 x LED 1 x 220Ω Resistor 2 x 1N4007 Diodes 1 x 50KΩ Potentiometer 1 x 10nF Capacitor 1 x 100nF Capacitor and a 5V Battery How This Circuit Works Based on the charging and discharging timings of the Capacitor, a PWM Signal is generated at PIN 3 (OUT PIN) of the 555 Timer IC. The output is then sent to the LED to produce the dimming effect. Demo So, this is how it looks like. By rotating the knob of the 10K Pot we can adjust the brightness of the connected LED. With Arduino Now, lets repeat these setups using an Arduino. The beauty of Arduino is that it has 6 digital pins that can be used as PWM outputs (3, 5, 6, 9, 10, and 11). PWM signals are sent using the analogWrite() function by passing a value between 0 - 255. - analogWrite(255) requests a 100% duty cycle (always on), - and analogWrite(127) is a 50% duty cycle (on half the time), and so on. Components Required For this setup we need: Arduino UNO/Nano whatever is handy 1 x Breadboard 1 x LED 1 x 220Ω Resistor 1 x 10KΩ Potentiometer Automatic Fading Connect the positive leg of your LED to the digital output PIN9 of your Arduino through a 220Ω resistor. Connect the negative leg directly to the GND. That it, that's how simple it is. The Code After declaring PIN 9 as LedPin, and setting up the pinMode in the setup() section, we are going to loop through and dim the LED in the loop section. By gradually increasing the PWM value from 0 to 255, and then back to 0 we can get the fading effect. In this sketch, the PWM value is set using a variable called 'brightness'. Each time in the loop, it increases by the value of the variable 'fadeAmount'. If brightness is at either extreme of its value (either 0 or 255), then 'fadeAmount' is changed to its negative. So, if the fadeAmount is 5, then it is set to -5 and if it is -5, then it is set to 5. The next time through the loop, this change causes brightness to change its direction. A delay is added to control the speed of the fading effect. Demo So, this is how it looks like. Manual Fading Connect the positive leg of your LED to the digital output PIN6 of your Arduino through a 220Ω resistor. Connect the negative leg directly to the GND. Connect the left (or right) pin of the 50KΩ PoT to VCC and then connect the right (or left) pin of the PoT to the GND. Now, connect the 'data' pin of your potentiometer to the Analog PIN 'A0' of the Arduino. In this circuit, the potentiometer is working as a voltage divider. One of the outer pins is connected to the GND, the other to Vcc and the middle pin is the voltage output. The wiper position in this setup determines the output voltage. Now, lets have a look at the code. The Code Based on my setup, I set the LedPin as 6 and Potentiometer pin Pot as A0. Another variable 'Knob' is used to read and store the value of the potentiometer. pinMode of the LedPin is set to OUTPUT and we don't need to do anything for the PoT as its default value is already set as input. In the 'loop()' section I am first reading the value of the PoT using the 'analogRead()' function and then mapping its value between 1 to 255. A potentiometer intakes a value between 1 and 1024, but in our setup it has to be between 1 to 255. The 'map()' function divides the value read from the potentiometer into equal intervals of 1/255, which is then sent to the LED using the 'analogWrite()' function. Demo So, this is how it looks like. Thanks Thanks again for checking my post. I hope it helps you. If you want to support me subscribe to my YouTube Channel: https://www.youtube.com/user/tarantula3 Full Blog Post: https://diy-projects4u.blogspot.com/2021/02/led-fader-with-or-without-arduino.html Video: https://youtu.be/IIUsdICycOw Gerber File: 1. Gerber : https://drive.google.com/file/d/1w1hHZBFsXQR74ZTn04097awaAUqMndJi/view?usp=sharing The Code: 1. Automatic Fading : https://drive.google.com/file/d/1hab3sISIlurrPQBat80OLb90RXqQKzLZ/view?usp=sharing 2. Manual Fading Using PoT : https://drive.google.com/file/d/1TzXdVO5lVjPNaw_NPSUexIye3WZGJ6cj/view?usp=sharing Sketches: https://drive.google.com/file/d/1_WtmESof7kSyuJ_cmkkFZ8E8mdQXl3Z9/view?usp=sharing BTC: 1M1PdxVxSTPLoMK91XnvEPksVuAa4J4dDp LTC: MQFkVkWimYngMwp5SMuSbMP4ADStjysstm DOGE: DDe7Fws24zf7acZevoT8uERnmisiHwR5st ETH: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 BAT: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 LBC: bZ8ANEJFsd2MNFfpoxBhtFNPboh7PmD7M2 Thanks, ca again in my next tutorial.
  15. A Chaser Circuit consists of a clocked IC or other electronic unit like an Arduino that drives an array of LEDs in such a way that individual LEDs (or small groups of LEDs) turn on and off in a predetermined and repeating sequence, thus producing a visually attractive display in which one or more ripples of light seem to repeatedly run through a chain or around a ring of LEDs. In this tutorial I am going to create 3 chaser circuits using Arduino and IC4017 decade counter. https://youtu.be/F6V1AjESWbU Sponsors This video is sponsored by PCBWay. PCBway: only $5 for 10 pcbs from https://www.pcbway.com/ PCBWay specialize in manufacturing of very high quality, low-volume, colored PCBs at a very budgetary price. In addition to the standard PCBs, you can also order Advanced PCBs, Aluminum PCBs, FPC/Rigid-flex PCBs. They also provide PCB assembly and other related service which can meet your needs to the greatest extent. The ordering process from PCBWay is very easy. Once I had my design ready, I just had to upload the gerber file to the PCBWay's website and select the type, color and any other customization that I want and then just send it for fabrication. For my project, I choose the black color. PCBWay ships from china to most of the countries of the world within 3 to 7 business days. Talking about the quality, its absolutely mind-blowing. Using IC555 and IC4017 Lets first create the chaser circuit using the IC4017 decade counter and IC555 timer IC. Components Required For the Non-Arduino bit we need: 2 x 4017 Decade Counter IC 1 x 555 Timer IC 1 x 10 K Potentiometer 1 x 1 Kilo Ohm Resistor 1 x 100 Ohm Resistor 1 x 100 MFD Capacitor 20 x Zener Diodes and 10 x Red LEDs Circuit Diagram 1. Forward Chaser The circuit is very simple. The 555 Timer IC operates as a clock oscillator or clock generator. The output on PIN-3 goes high causing a shift. The signal from the 555 IC clocks the 4017 decade counter. Output of 555 timer IC on PIN-3 is given as an input to 4017 IC through PIN-14. Whenever a pulse is received at the input of IC 4017, the counter increments the count and activates the corresponding output PIN. This IC can count upto 10, so we have attached 10 LEDs to the circuit. By increasing or decreasing the value of resistance of the 10K pot we can adjust the speed of the chaser circuit. Since only one LED will be turned on at a given time, I have attached just one 220ohm current limiting resistor to the cluster of LEDs. Demo: So this is how it looks like. 2. Forward Reverse Chaser using 2 x IC4017 Now, to give the forward and reverse effect we are attaching another 4017 IC to this circuit. If lets say the 1st IC connects from 1 to 10 (left to right) then the second one should connect from 10 to 1 (right to left). However, now we cannot connect the counter ICs directly to the LEDs as we did before. We have to use Diodes to stop the reverse flow of current to the 2nd IC. We have also lowered the value of the current limiting resistor to 100ohms as at a given time 2 LEDs will be on, one running from left and one from the right hand side. Demo: Now lets do a quick test. By lowering the speed I can get the desired forward and reverse effect. By removing one of the 4017 ICs we can get the effect that I demonstrated in the previous example. 3. Forward Reverse Chaser using 1 x IC4017 To get a forward reverse effect using one 4017 IC we need to connect 8 diodes to the circuit. The 1st and the 6th LED will be directly connected to the IC4017. The LEDs at the far end will get signals from only one pin however the one in the middle will receive signals from 2 x pins and hence we need diodes to stop the reverse flow of the current. Demo: So this is how it looks like. Using Arduino Now, I am going to repeat the same setup using an Arduino. Components Required For the Arduino bit we need: 1 x Arduino Uno/Nano (whatever is handy) 1 x 220 Ohm Resistor 10 x Red LEDs Few Connecting Cables The beauty of using an Arduino is that the setup remains the same for all the previously shown circuits, the only thing that changes is the code. So, I am going to use this simple setup for the rest of the tutorial. Circuit Diagram 1. Forward Chaser Code: The code for the forward chaser is very simple. Start by defining the constants and the global variables that will be used throughout the code. Then in the setup section define the pin modes. Now, in the loop section we are going to start by turning off all the LEDs followed by turning one LED on at a time. A counter is used to tell the loop which LED to turn on in the next cycle. Once the value of the counter reaches 10 (the maximum number of LEDs) the counter resets to 1 and the 1st LED lights up and the cycle continues. Demo: So this is how it looks like. 2. Forward Reverse Chaser Code: The code is same as the previous setup. The only thing that changes is the function that deals with the LEDs. In this setup we cycle through LED 1 to LED 10 and then reverse from LED 9 to LED 1. The counter resets when the max count is reached. Demo: So this is how it looks like. 3. Left-Right Chaser Code: The setup is exactly the same as the previous two setups. This function is the one which turns on the LEDs at the two far ends and then the one before that and likewise until they cross each other. The counter is reset when the max count is reached. Demo: So this is how it looks like. PCF8574 8-bit GPIO Port Extender Using a PCF8574 8-bit GPIO Port Extender we can add even more LEDs to this setup. PCF8574 becomes a life saver when you run out of pins on your Arduino. This "GPIO (General Purpose Input Output) pin extender" provides an additional 8 pins (P0 ~ P7) which can be used to 'output a signal' or 'read a signal as an input'. These modules run on the I2C bus, and if daisy-chained you can connect upto 8 of these devices in a project. Each device will give us an additional 8-bits of GPIO enabling 64 GPIOs in total. To know more about this IC please check out my tutorial number 10 : "PCF8574 GPIO Extender - With Arduino and NodeMCU". Thanks Full Blog Post: https://diy-projects4u.blogspot.com/2021/01/led-chaser-circuits-using-ic4017-and.html Video: https://youtu.be/F6V1AjESWbU Gerber File: 1. https://drive.google.com/file/d/108EUNylmearJgU_4qSlxNr9GAPGrLGRh/view?usp=sharing Code: 1. Forward: https://drive.google.com/file/d/1bw1la5oRMWZRXsfYJ41qNbCoEkJsZHBM/view?usp=sharing 2. Forward Reverse: https://drive.google.com/file/d/1Oag8kxbvfxZg7StFrYzWwtcqQx6okwzd/view?usp=sharing 3. Left Right: https://drive.google.com/file/d/17ZEsKU3OFrcjaJpvyUJMQbHQ-lznbp0H/view?usp=sharing Sketch: 1. With Arduino: https://drive.google.com/file/d/1YHWvpkDbGbGVHwX65HwvwS3_JyFwZdK9/view?usp=sharing 2. Without Arduino: https://drive.google.com/file/d/1LdxcS1BXf3GtQTRhWCoCZKm6ppRwsc5k/view?usp=sharing BTC: 1M1PdxVxSTPLoMK91XnvEPksVuAa4J4dDp DOGE: DDe7Fws24zf7acZevoT8uERnmisiHwR5st LTC: LedWPdTaUzr5iaJx8garkcykSs1DZU1FAx ETH: 0xB62a901Ee6cE24f3153CA6ae565C2A6533066faA BAT: 0xB62a901Ee6cE24f3153CA6ae565C2A6533066faA BCH: 14xJhpswSAQi375S39yDFsrBFtDoiLVX1J
  16. Trying to explain dialup to a pre-teen will evoke the same wild-eyed bewilderment as “a dinosaur was as-big-as this house”. We can’t go off what our parents did because two tin cans connected by a string isn’t really the same these days and probably it would look like a piece of junk for the new and upcoming generations. However, the truth is "life is busy" and hence we don’t spend enough time with our children. Children need high-quality time with parents and caregivers - the QUALITY of time spent with them is much more important than the QUANTITY of time. Christmas was the perfect time to explore and setup this bonding. With a bit of help from my little monster and by using The Most Complete Starter Kit from ELEGOO I created this small Christmas Village for my little monster. https://youtu.be/j9d58jL1THU Components Used [Village Creation] ----------------------------------------------- To create the cardboard village we need: Cardboard Sheets A4 Paper Permanent Marker or Pen Scissor and a Knife Hot Glue Gun or Wood Glue Adding a bit color would have made my project even more attractive however I just left it all in white. Paper Templates --------------------- I created 2 x PDF files with all the measurements in it. The links to the PDF files is in the description below. After printing the PDFs on A4 sheet, I extracted the shapes from it using a paper cutting scissor. Cutting The Cardboard ------------------------------- Then I traced the paper-cutouts on pieces of cardboard and using both scissor and knife I extracted all the pieces of cardboard that I need for this project. Using a hot-glue gun I joined all the cardboard cutouts. Be very careful while using a hot-glue gun. Use gloves as much as possible to avoid the hot glue from burning your hand and fingers. By using wood-glue instead of hot-glue you can get a cleaner and stronger finish, but hot glue is faster. Hot glue can also be more forgiving as you can re-heat and re-glue if you're unsatisfied with your seam. Try applying the glue from the inner side as much as possible to leave the outer side neat and clean. Meaningful connections are all about quality of time and not quantity of time. Keep it simple and connect with your child in ways that make sense for your lifestyle and relationship. Each connection has a lasting impact and provides the support and reassurance that your child needs. Although the days with little kids often seem long; however, the years fly-by. Use this practical and purposeful blueprint to enjoy the moments you have together. Color or Not To Color ---------------------------- So, this is how it looks like. As advised earlier, adding a bit color would have made my project even more attractive however I just left it all in white. I created this wooden frame on which the village will sit. This frame will also house the electronic components inside it. Components Used [Electronics] ---------------------------------------- Now for the Electronics bit we need the "The Most Complete Starter Kit from ELEGOO". This kit has all the components that are required for this project. 1 x ELEGOO UNO R3 9 x Blue LEDs 9 x White LEDs 5 x Yellow LEDs 1 x RGB LED 3 x 220 Ohm Resistor 1 x Stepper Motor 1 x Stepper Motor Driver 1 x LDR Adding LEDs ----------------- Using the soldering iron I made few holes around the pathway. These holes are for the Blue and White LEDs which will blink alternately. Adding RGB-LEDs would have definitely given this a better look and feel. Next, I added a RGB-LED to the water-feature. Later, I will add a bit of cotton on top of this which may look like flowing water. SUN & MOON ------------------- So, this is how the final setup looks like. I added some hills at the back for the rising and setting of the sun and the moon. The logic is very simple. A DC-Motor or Stepper-Motor rotates the Half Sun and Half Moon. A LDR is placed in a way that the Sun rays can cover it up. When the moon side is up the sun rays cove the LDR and vice-versa. This LDR acts as a switch and turns on and off the blue and white flashing LEDs. With the same logic you can go even more creative than what I did. Coding --------- The DC Motor run off the 5V pin of the Arduino so we don't need to code anything for that. For the rest of the code I am looping through and flashing the RGB LEDs followed by checking if the LDR has detected any light and then waiting for 200ms before repeating the process again. Thanks ---------- Thanks again for checking my post. I hope it helps you. If you want to support me subscribe to my YouTube Channel: https://www.youtube.com/user/tarantula3 Full Blog Post: https://diyfactory007.blogspot.com/2021/01/arduino-christmas-village.html Video: https://www.youtube.com/watch?v=j9d58jL1THU Code: https://drive.google.com/file/d/1RABIcytmGJo3m6ghkzk8KYoQmRycmBku/view?usp=sharing Cardboard Templates: Christmas Tree : https://drive.google.com/file/d/13NqyTz0WU1Q8qshmeGsMqV9j_K5hU0AN/view?usp=sharing Houses : https://drive.google.com/file/d/15hzvw0cuT9-XM3dqoUrUwIffBj5fQWff/view?usp=sharing Train : https://drive.google.com/file/d/1aGcprGGrlxslU2F8XmnmUZ1KYQZVORJ1/view?usp=sharing BTC: 35ciN1Z49Y1bReX2U7Etd9hGPWzzzk8TzF DOGE: DDe7Fws24zf7acZevoT8uERnmisiHwR5st LTC: MQFkVkWimYngMwp5SMuSbMP4ADStjysstm ETH: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 BAT: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 Thanks, ca again in my next tutorial.
  17. Tutorial - Reed switch Reed switch was invented in 1936 by Walter B. Ellwood in the Bell Telephone Labs. Reed Switch consists of a pair of ferromagnetic (something as easy to magnetize as iron) flexible metal contacts typically nickel-iron alloy (as they are easy to magnetize and doesn't stay magnetized for long) separated by only a few microns, coated with a hard-wearing metal such as Rhodium or Ruthenium(Rh, Ru, Ir, or W) (to give them a long life as they switch on and off) in a hermetically sealed (airtight) glass envelope (to keep them dust and dirt free). The glass tube contains an inert gas (An inert gas is a gas that does not undergo chemical reactions under a set of given conditions) typically Nitrogen or in the case of high voltage it is just a simple vacuum. In production, a metal reed is inserted in each end of a glass tube and the end of the tube heated so that it seals around a shank portion on the reed. Green-colored Infrared-absorbing glass is frequently used, so an infrared heat source can concentrate the heat in the small sealing zone of the glass tube. The glass used is of a high electrical resistance and does not contain volatile components such as lead oxide and fluorides which can contaminate the contacts during the sealing operation. The leads of the switch must be handled carefully to prevent breaking the glass envelope. When a magnet is brought in close proximity to the contacts, an electro-mechanical force field is generated and the stiff nickle iron blades become magnetically polarized and gets attracted to each other, completing the circuit. When the magnet is removed the switch returns to its open state. Since the contacts of the Reed Switch are sealed away from the atmosphere, they are protected against atmospheric corrosion. The hermetic sealing of a reed switch makes them suitable for use in explosive atmospheres where tiny sparks from conventional switches would constitute a hazard. A Reed Switch has very low resistance when closed, typically as low as 50 milliohms hence a Reed Switch can be said to require zero power to operate it. Components ------------------ For this tutorial we need: - Reed Switch - 220Ω Resistor - 100Ω Resistor - LED - Multi-meter - Battery - Breadboard - Arduino Nano - Magnets and - Few Connecting Cables Demo -------- Using a multi-meter I am going to show you how a Reed Switch works. When I bring a magnet close to the switch the multi-meter shows a continuity as the contact touches each other to completing the circuit. When the magnet is removed, the switch returns to its normally open state. Types of Reed Switches ---------------------------------- There are 3 basic types of Reed Switches: 1. Single Pole, Single Throw, Normally Open [SPST-NO] (normally switched off) 2. Single Pole, Single Throw, Normally Closed [SPST-NC] (normally switched on) 3. Single Pole, Double Throw [SPDT] (one leg is normally closed and one normally open can be used alternate between two circuits) Although most reed switches have two ferromagnetic contacts, some have one contact that's ferromagnetic and one that's non-magnetic, while some like the original Elwood reed switch have three. They also vary in shapes and sizes. Connecting Without Arduino ----------------------------------------- Lets first test the Reed Switch without an Arduino. Connect a LED in series with the Reed Switch to a battery. When a magnet is brought in close proximity to the contacts, the LED lights up when the nickle-iron blades inside the switch attracts each other, completing the circuit. And, when the magnet is removed the switch returns to its open state and the LED turns off. Connecting Reed Switch to Arduino --------------------------------------------------- Now, lets connect the Reed Switch to an Arduino. Connect the LED to the pin 12 of the Arduino. Then connect the Reed Switch to the pin number 13 and ground the other end. We also need a 100ohm pull-up resistor connected to the same pin to allow a controlled flow of current to the digital input pin. If you want, you can also use the internal pull-up resistor of the Arduino for this setup. The code is very simple. Set the pin number 13 as Reed_PIN and pin number 12 as LED_PIN. In the setup section, set the pin-mode of the Reed_PIN as input and LED_PIN as output. And Finally in the loop section, turn on the LED when the Reed_PIN goes low. Same as before, when a magnet is brought in close proximity to the contacts, the LED lights up and, when the magnet is removed the switch returns to its open state and the LED turns off. Reed Relay ---------------- Another widespread use of Reed Switch is in the manufacturing of Reed Relays. In a Reed Relay the magnetic field is generated by an electrical current flowing through an operating coil which is fitted over "one or more" Reed Switchs. The current flowing in the coil operates the Reed Switch. These coils often have many thousands of turns of very fine wire. When the operating voltage is applied to the coil a magnetic field is generated which in turn closed the switch in the same way the permanent magnet does. Compared to armature-based relays, Reed Relays can switch much faster, as the moving parts are small and lightweight (although switch bounce is still present). They require very less operating power and have lower contact capacitance. Their current handling capacity is limited but, with appropriate contact materials, they are suitable for "dry" switching applications. They are mechanically simple, offer high operating speed, good performance with very small currents, highly reliable and have long life. Millions of reed relays were used in telephone exchanges in the year 1970s and 1980s. Areas of Application ----------------------------- Just about everywhere you go, you'll find a Reed Switch nearby that’s quietly doing its job. Reed switches are so pervasive that you’re probably never more than a few feet away from one at any given time. Some of their areas of application are in: 1. Burglar alarm systems for the doors and windows. 2. Reed switches puts your laptop to sleep/hibernation when the lid is closed 3. Fluid level sensors/indicator in a tank - a floating magnet is used to activate the switches placed at various levels. 4. Speed sensors on bicycle wheels/ DC electric motors 5. In the spinning arms of dishwashers to detect when they jam 6. They keep your washing machine from running when the lid is open 7. In the thermal cut-offs in electric showers, to stop the water heating to dangerous levels. 8. They know if the car has enough brake fluid and whether or not your seat belt is fastened. 9. Anemometers with rotating cups have reed switches inside that measure the speed of the wind. 10. They are also used in applications which make use of their extremely low leakage of current. 11. Old keyboards, in vehicles, industrial systems, Household appliances, telecommunication, medical appliances, Clamshell phones and more...... On the relays side they are used for automatic cut sequences. Life ----- The mechanical motion of the reeds is below the fatigue limit of the materials, so the reeds do not break due to fatigue. Wear and life are almost entirely dependent on the electrical load's effect on the contacts along with the material of the reed switch. Contact surface wear occurs only when the switch contacts open or close. Because of this, manufacturers rate life in number of operations rather than hours or years. In general, higher voltages and higher currents cause faster wear and shorter life. The glass envelope extended their life and can be damaged if the reed switch is subjected to mechanical stress. They’re cheap, they’re durable, and in low-current applications, depending on the electrical load, they can last for about a billion actuation. Thanks ---------- Thanks again for checking my post. I hope it helps you. If you want to support me subscribe to my YouTube Channel: https://www.youtube.com/user/tarantula3 Full Blog Post: https://diy-projects4u.blogspot.com/2020/07/reed-switch.html Video: https://youtu.be/WA1tp-f81p8 Support my work: BTC: 35ciN1Z49Y1bReX2U7Etd9hGPWzzzk8TzF LTC: MQFkVkWimYngMwp5SMuSbMP4ADStjysstm ETH: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 DOGE: DDe7Fws24zf7acZevoT8uERnmisiHwR5st TRX: TQJRvEfKc7NibQsuA9nuJhh9irV1CyRmnW BAT: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 BCH: qrfevmdvmwufpdvh0vpx072z35et2eyefv3fa9fc3z #ReedSwitch #ReedRelay #Arduino
  18. The very first program you write when you start learning a new programming language is: "Hello World!". The program itself does nothing more than printing a “Hello World” text on the screen. So, how do we get our Arduino to display the "Hello World!"? In this video, I will be showing you how to get started with the small 0.91 (128x32) and 0.96 (128x64) I2C OLED displays. There are 100s of tutorials on the web explaining the same thing in different ways, but I couldn't find one that tells me all about the OLED display and how to use it in different scenarios. It took me some time to work it all out. So, I thought I should create a tutorial on what I have learned and combine all the features and ways the OLED displays can be used in our projects. Step 1: Things We Are Going to Learn Today In this video we will be talking about: - What is an OLED display? - Then we will have a closer look at the 0.91 (128x32) and 0.96 (128x64) I2C OLED displays - Next we will talk about installing the Adafruit Library to your Arduino IDE - Then we will connect NodeMCU and Arduino to an OLED display - Next we will have a look at the code and display some graphics and text on it - We will also talk about applying Custom Fonts and displaying Images - Then we will connect Multiple OLEDs to a micro-controller using I2C Multiplexer - Finally, we will talk about few common errors people make while using the OLED displays Step 2: Hardware Requirement For this tutorial we need: - A Breadboard - A 0.91" (128x32) and 0.96" (128x64) I2C OLED displays - Arduino UNO/NANO (whatever is handy) - NodeMCU - TCA9548A I2C multiplexer - Few Connecting Cables - and a USB cable to upload the code Step 3: What Is an OLED Display? OLED or organic light-emitting diode is a light-emitting diode (LED) in which the emissive electroluminescent layer is a film of organic compound (millions of small LED lights) that emits light in response to an electric current. OLEDs are used to create digital displays in devices such as television screens, computer monitors, portable systems such as mobile phones, hand-held game consoles and PDAs. An OLED display works without a backlight because it emits visible light. There are many types of OLED displays available in the market based on their - Sizes - Color - Brands - Protocol - SPI (Serial Peripheral Interface) or I2C - Passive-matrix (PMOLED) or active-matrix (AMOLED) control scheme In this tutorial, I am going to talk about connecting the blue color 0.91 (128x32 OLED) and 0.96 (128x64 OLED) I2C OLDE displays to an Arduino NANO and NodeMCU. I2C bus technology uses only 2 pins of the MCU so we have heaps available for other sensors. Step 4: Closer Look Lets have a closer at these two displays. At the back of these displays there are heaps of SMD capacitors and resistors soldered on-board; but, since its an I2C device we only care about these 2 pins (SCL and SDA) The display connects to Arduino using only four wires – two for power (VCC and GND) and two for data (serial clock SCL and serial data SDA), making the wiring very simple. The data connection is I2C (I²C, IIC or Inter-Integrated Circuit) and this interface is also called TWI (Two Wire Interface). - The on-board pins can be in different order, so always triple check before hooking it up to your project. - Operation voltage is between 3v to 5v but, it is best to use the guidance from the manufacturer's datasheet. - Sometimes we need to use 2 displays in our projects. So, how can we achieve this? The trick is to have a configurable address on your display. This unit has a configurable address between 0x78 and 0x7A. Just by unsoldering the 0Ohm resistor from one side and hoking it up to the other side or just by putting a global solder we can change the address. We will talk about it in depth when we hook up multiple displays to an Arduino in the later section of this tutorial. In picture these displays look very big. But, practically speaking they are tiny. They are made of 128 x 32/64 individual OLED pixels and do not require any back-light. Just have a look at this and see how small it is. Even though they are small they can be very useful in any electronic projects. Step 5: Library There are several libraries available to control these displays. In past I have used the "u8glib library" but I find the AdaFruit library very easy to understand and use in our projects. So, I am going to use the AdaFruit library in this tutorial. To control the OLED display you’ll need the "adafruit_GFX.h" library and the "adafruit_SSD1306.h" library. There are two ways you can download and install the library to your Arduino IDE. Method 1 Go to the "Library manager" and search "adafruit_SSD1306" and "adafruit_gfx" Select the latest version and hit the Install button. Once installed you can use these libraries in your program. Method 2 These two libraries can be also be downloaded from github (you need both): I will provide the links in the description below. The display library: https://github.com/adafruit/Adafruit_SSD1306 The GFX library: https://github.com/adafruit/Adafruit-GFX-Library Once downloaded, copy the Adafruit_SSD1306-master folder from the downloaded zipped file into the Arduino libraries folder. This folder is usually found at Documents > Arduino > libraries on Windows systems. On Linux it is usually found at home folder > Arduino > libraries. Finally in the Arduino library folder, rename the Adafruit_SSD1306-master folder to Adafruit_SSD1306. Even if you don’t rename that’s fine. Now, lets have a look at the "Adafruit_SSD1306.h" file Two things we need to know in this library: 1. If you want to use the smaller display use the default 128_32 otherwise for the bigger display comment the 128_32 and uncomment the 128_64 2. If you have soldered the 0x7A Address on the board (which we will talk about later) then use the 7 bit 0x3D address for the bigger displays, otherwise use the default 0x3C address. For the smaller displays the address is 0x3C. Step 6: Wiring 128 X 64/32 OLEDs Lets start by connecting the NodeMCU to the display. The first and most important thing to note is that some of the displays may have the GND and VCC power pins swapped around. Check your display to make sure that it is the same as the image. If the pins are swapped, make sure to change the connections to the Arduino or NodeMCU. - NodeMCU OLED Wiring OLED VCC – NodeMCU 3.3V OLED GND – NodeMCU GND OLED SCL – NodeMCU D1 OLED SDA – NodeMCU D2 - Arduino Uno OLED Wiring OLED VCC – Arduino 5V OLED GND – Arduino GND OLED SCL – Arduino Uno A5 OLED SDA – Arduino Uno A4 - Arduino MEGA 2560 OLED Wiring OLED VCC – Arduino 5V OLED GND – Arduino GND OLED SCL – Arduino MEGA 2560 pin 21 OLED SDA – Arduino MEGA 2560 pin 20 Step 7: Code Adafruit library comes with really good examples for both 128x32 and 128x64 displays. The Library is located under File > Examples > Adafruit SSD1306 > and then the display type in the Arduino IDE. We are going to use the 128x32 I2C example and will modify it to work with both 128x64 and 128x32 displays fist by hooking it up to an Arduino and then to a NodeMCU board. The code starts by including both the Adafruit libraries. In this tutorial I am going to stress on only those parts of the code which are necessary for us to load on both boards and displays. If you want to know more about the code please drop a comment on my blog or in the comments section below and I endeavour to get back to you. - First we are going to load the code to an Arduino Nano connected to a 128x32 display. We can use the code as is without any modifications. 128x32 uses 0x3C address so this bit looks all good here, lets double check the header library, yes its also using the 0x3C address and the display type is 128x32. - Now lets connect the 128x64 display. As we know it uses the 0x3C address by default so we don't need to update the address in either the code or the library. We just need we need to comment the 128_32 and uncomment the 128_64 in the header library and change the LCDHEIGHT to 64 in our code. - Now to run the same code on a NodeMCU we need to change one more line in our code. The "#define OLED_RESET 4" > "#define OLED_RESET LED_BUILTIN" rest of the code is same as Arduino Pretty much to display anything we first need to clear the previous screen using display.clearDisplay(); // Clear the buffer Then draw the object testdrawline(); // Draw a line Show it on the hardware display.display(); // Make them visible on the display hardware! Wait for some time before displaying the next item. delay(2000); // Wait for 2 seconds In this example we are displaying few items like text, lines, circles, scrolling text, triangles and more. Go ahead and use your imagination and display whatever you want on these tiny displays. Attachments Libraries.zip Download NodeMCU.zip Download Step 8: Customizing Text & Adding Images Sometimes your code needs to display custom fonts and images. If you are very good in bit mapping then you just need to create a byte arrays by turning on or off the tiny LEDs of the display to create custom fonts and images. However, I am not very good in doing these mappings and don't want to spend hours creating the bit map tables. So, what are my options? I generally use two websites to generate custom fonts and images. The links are provided in the description below. Custom Fonts ------------ Go to the font converter website, select the font family, style, size, Library Version as "Adafruit GFX Font" and then hit the "Create" button. On the right hand side of this page you can see how your font is going to look like on the actual display. Based on your selection the webpage generates the fonts header file. Create a file called "modified_font.h" in the same folder where your code is and copy and save the generated code into it. Then you just need to include the header file in your code to use the custom font. #include "modified_font.h" Then, you just need to set the font before displaying the text to apply the custom font to it. display.setFont(&Your_Fonts_Name); You can get the name of the font from the header file you just added to your project. Thats it, easy. Memory is always a concern while using custom fonts, so always consider the bytes that will be consumed by the memory. Just remember Arduino UNO has only 32K of memory. Custom Images ------------- To display a bitmap image on your screen you first need to create a 128 x 64/32 sized image. I am using the good old "MS Paint" to create a 128 x 64 bitmap image which I will then upload to this image converter website. The website converts images into byte-strings, which can be used with Arduino and OLED displays. Start by uploading the image to the website. Then put a check on the "Invert image colors" check-box and change the "Output code format" to "Arduino Code" next select the orientation and hit the "Generate Code" button to generate the byte array. The "Preview" section shows you how your image will look like on the actual display. I have included the code along with this tutorial which you can use to display your images. You just need to replace the array in my code with the one you just generated and then load it to your Arduino. Attachments Custom_Font.zip Download Custom_Image.zip Download Step 9: Connecting 2 Displays Connecting two 128 x 64 displays to your project is easy. You just need to unsolder the 0Ohm resistor from 0x78 address and put it on 0x7A and then use the 0x3D address in your code instead of the default 0x3C. You must be wondering why we are using the 0x3C and 0x3D address and not the actual 0x78 and 0x7A. Arduino accepts 7-bit address and not the 8-bit hardware addresses. So, we first need to convert the 8-bit address to binary, and then chop off the least significant bit to get the 7 bits. Then convert the 7 bits to HEX to get the 0x3C or 0x3D addresses which you enter in your code. First, initialize the display by giving it a unique name: Adafruit_SSD1306 display1(OLED_REST); Adafruit_SSD1306 display2(OLED_REST); Then in your code use the display 1 and display 2 to call the begin statements with the device addresses in them: display1.begin(SSD1306_SWITCHCAPVCC, 0x3C); // display 1 op address 0x3C display2.begin(SSD1306_SWITCHCAPVCC, 0x3D); // display 2 op address 0x3D That's it, you can now go ahead and do whatever you want using either Display 1 or Display 2 in the rest of your code. I have provided an example with this tutorial. Wiring is exactly the same as what we have done before, pretty much you just need to add another display to the same I2C pins of either the Arduino or NodeMCU. Based on the addresses, the MCU then sends the data on the I2C data line. Attachments Two_OLEDs.zip Download Step 10: Connecting More Than 2 Displays 3 More Images Now, what if you want to hook up more than 2 displays? Arduino has limited number of pins and hence you cannot have more than a certain amount of shields attached to it. Moreover, it has only one pair of I2C buses. So, how can we attach more than 2 I2C displays to an Arduino? The trick is to use a TCA9548 Multiplexer. TCA9548 allows a single micro-controller to communicate with up to '64 sensors' all with the same or different I2C address by assigning a unique channel to each sensor slave sub-bus. When we talk about sending data over 2 wires to multiple devices we then need a way to address them. Its same as the postman coming on a single road and dropping the mail packets to different houses because they have different addresses written on them. The Multiplexer connects to 3V3, GND, SDA and SCL lines of the micro-controller. The slave sensors are connected to one of eight SCL/SDA slave ports on the board. The channels are selected by sending the TCA9548A its I2C address (0x70 {default} - 0x77) followed by the channel number (0b00000001 - 0b10000000). You could have at the max 8 of these multiplexers connected together on 0x70-0x77 addresses in order to control 64 of the same I2C addressed parts. By connecting the three address bits A0, A1 and A2 to VIN you can get different combination of the addresses. I will explain this in-depth in my next tutorial on TCA9548A breakout board. For now, lets just hook up 8 OLEDs to this board and have a quick look at the code. Connection: VIN to 5V (or 3.3V) GND to ground SCL to I2C clock SDA to I2C data Then wire up the sensors to VIN, GND and use one of the SCn / SDn multiplexed buses Now, Int the code lets start by including the "Wire" library and by defining the multiplexers address. #include "Wire.h" #include #define MUX_Address 0x70 // TCA9548A Encoders address Then we need to select the port we want to communicate to and send the data on it using this function: void tcaselect(uint8_t i) { if (i > 7) return; Wire.beginTransmission(MUX_Address); Wire.write(1 << i); Wire.endTransmission(); } Next we will initialize the display in the setup section by calling "u8g.begin();" for each display attached to the MUX "tcaselect(i);" Once initialized, we can then do whatever we want just by calling the function "tcaselect(i);" where "i" is the value of the multiplexed bus and then sending the data and clock accordingly. Attachments I2C_Port_Scanner.zip Download Multipe_OLEDs.zip Download Step 11: Advantages and Disadvantages The image of an OLED is beautiful. However, OLEDs also have disadvantages. Because OLED screens contain organic material, their lifespan is shorter than LCD displays. Additionally, many OLED displays get burn-ins after showing the same image for a long time. After a burn-in, the image stays on the screen even after showing another image. So make sure you keep refreshing the screen every few seconds. Water can instantly damage the organic materials of these displays. Advantages No need for a backlight Displays are very thin and lightweight Low power consumption Viewing angles are wider than LCDs Brightness and contrast are great High speed and have low response time Deep black color Disadvantages Costly technology Short lifecycle OLEDS are more likely to burn-in Water damage Step 12: Common Errors To conclude the tutorial lets talk about few common errors people make while using these displays: - Always triple check the pins before using it in your project - Pick up the right library address in the header file and in your code #define SSD1306_I2C_ADDRESS 0x3C // in Adafruit_SSD1306.h and display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // in your code If the address is wrong the OLED will not display anything - The display size must be changed in the driver before it can be used. If it is not changed you will get an error message when attempting to verify the code #error ("Height incorrect, please fix Adafruit_SSD1306.h!"); - If using NodeMCU make sure you replace the OLED_RESET from 4 to LED_BUILTIN #define OLED_RESET LED_BUILTIN I have scene people making all sorts of things using this OLED display. Some have even made video games and all. I am really not interested in making a video game using this tiny display. However, I will now leave you to explore your imaginations and come out with amazing ideas. - Blog: http://diyfactory007.blogspot.com.au - Add Image: http://javl.github.io/image2cpp/ - Custom Text: http://oleddisplay.squix.ch/#/home - Adafruit display library: https://github.com/adafruit/Adafruit_SSD1306 - Adafruit GFX library: https://github.com/adafruit/Adafruit-GFX-Library - u8glib library: https://code.google.com/archive/p/u8glib/ or https://github.com/olikraus/u8glib If you want to use the smaller display use the default 128_32 otherwise for the bigger display comment the 128_32 and uncomment the 128X64 NO_ACK in your code (just uncomment the type of screen you are using) (fonts are in the fonts library) Attachments DataSheets.zip Download LCD-U8glib.zip Download OLED_Graphing.zip Download Schema.zip Download
  19. Has this ever happened to you? You come back from a romantic dinner date and when you open the shutter door of your garage you realize that you left the garage light ON. You spent few hours outside with your partner to impress her and all the time this light bulb was on. You immediately turn around and look at her face to see a silent anger on her face. Alright, enough of that. So, in this tutorial, I am going to turn on and off the garage light using a PIR sensor. When the sensor detects a moving object, it turns on the light bulb and when the moving object is gone, it turns it off. Lastly, I am going to make sure that light bulb only turn on during the night time (when its dark). Step 1: Logic In this project, I will be using a PIR sensor along with an LDR to turn on or off a light bulb using a Relay. The things I need to consider before designing the circuit are: - The bulb should only turn on when the room is dark and when a motion is detected. - The bulb should turn off after 30 seconds of the object leaving the sensors proximity. - Most important, we need to place the LDR in a place where it doesn't turn off the bulb as soon as it lights up. Step 2: Hardware For this tutorial we need: A General Purpose PCB 2 x HC-SR501 PIR Sensor 2 x 1N4148 Small Signal Fast Switching Diodes 1 x 1N4007 High Voltage, High Current Rated Diode to protect the micro-controller from voltage spikes 1 x LDR 1 x 10K Trimmer Potentiometer 2 x 470 Ohms Resistor 1 x 10K Resistor 1 x 1K Resistor 1 x 2N3906 General Purpose PNP Transistor 1 x 2N2222 General Purpose NPN Transistor 1 x 5V Relay 1 x LED to display the status 5 x Terminal Blocks 1 x 220V to 5V Buck Step Down Module Few Connecting Cables And General Soldering Equipments Step 3: Assembly Lets first connect the LDR and setup the light detection bit. As we all know we need to setup a voltage divider to use the LDR in a circuit, so, I am adding this 10K POT and 470ohms resistor to setup the voltage divider bit. By adjusting the resistance of the POT we can adjust the intensity of sunlight at which this circuit will operate. Now, lets install the PIR sensor. Connect the VCC to +5v and GND to ground. Then connect the 1N4148 diode to the OUT of the sensor. In this circuit, I am installing just one sensor however in the actual project I have used 2 sensors to capture a bit more than 180 degrees. So, to avoid the sensors from back-feeding each other we need to install a diode to the OUT pin of each sensor. If you want to capture motion at 360 degrees you may need 3 to 4 sensor and diode pair to achieve that. Now that we have the PIR sensor and the LDR in place we need to add the 'AND' functionality. To achieve this I am adding a general purpose PNP transistor. When a motion is detected 'and' when the sunlight is at a certain intensity (adjusted by the POT) current flows out of the transistor. Next, we need to amplify the current received from the collector of the PNP transistor and turn on and off the LED indicator and the Relay. A general purpose NPN transistor is used to achieve this. That's it all done. Step 4: What Have I Have Made So, this is what I have made. On my board components are pretty much soldered everywhere, but you may like to have them nicely installed to give it a bit more cleaner look. OK, so lets check out how this works. Step 5: Demo Alright, I have placed the board on this table to do a quick test. I haven't hooked up a light bulb to the circuit yet. However, the LED indicator should serve the purpose of this demonstration. So, now I am going to turn off the light and make the room dark. Let's see if the sensor picks up motion and lights up the LED. Tada, it works. Now, lets turn on the light of the room and see if the LED indicator turns off or not. Yessss, that works. OK, finally just want to make sure that the light bulb turns off after 30 seconds of me moving out of the sensors proximity. Boom, and that concludes the project. I can now install it on the ceiling and make my partner happy. Instead of having 2 to 3 PIR sensors you can use one and install it at the corner of the wall. However, that will require a fair bit of wiring either inside the roof or on the ceiling, which will be way more expensive and tedious than installing 3 sensors an d putting the device in the middle of the room. You can also swap the Arduino with a NodeMCU board and do a remote data logging to log the time when the sensor detected motion or when the light went on to record when people entered your garage and how long they stayed in there. Step 6: Areas of Applications of PIR Sensors This setup can be used to: * Automate All Outdoor Lights * Automate Lights of Basement, Garden or Covered Parking Areas * Automate Lift Lobby or Common Staircases Lights * Automate bedside or night lamp * Create a Smart Home Automation & Security System and more.. Step 7: Thanks Thanks again for watching this video! I hope it helps you. If you want to support me, you can subscribe to my channel and watch my other videos. Thanks, ca again in my next video.
  20. Just before creating my next projects tutorial, which will be using a PIR sensor, I thought I might create a separate tutorial explaining the working of a PIR sensor. By doing that I will be able to keep my other tutorial short and to the point. So, without wasting time let’s discuss what is a PIR sensor and how we can use it in our project. Step 1: Basic What is a PIR sensor? PIR or "Passive Infra-Red" sensor is a "Pyroelectric IR Sensor" which generates energy when exposed to heat. Everything emits some low level of radiation, the hotter the object is, the more radiation is emitted. When a human or an animal (with IR radiation wavelength of 9.4µMeter) approaches the sensors range the sensor detects the heat in the form of infrared radiation. The sensor only detects the energy emitted by other objects and don't produce any, that's why the sensor is called a PIR or "Passive Infra-Red" sensor. These sensors are small, cheap, rugged, low-power and very easy to use. Step 2: Hardware For this tutorial we need: 1 x Breadboard 1 x Arduino Nano/UNO (Whatever is handy) 1 x PIR Sensor 1 x LED and a 220 ohm current limiting resistor to test the connectivity Few connecting cables A USB cable to upload the code to the Arduino & General Soldering Equipments Step 3: Architecture As we can see the sensor has two sides: 1. Top or the Sensor Side 2. Bottom or the Components Side The Top consist of a specially designed 'High-Density Polythene' cover called "Fresnel Lens". This lens focuses the infrared rays to the underlying 'Pyroelectric Sensor'. 9.4 µMeter infrared rays can easily pass through the polyethylene cover. The sensors sensitivity range between 6 to 7 meters (20 feet) and the detection angle is 110 degrees x 70 degrees. The actual sensor is inside a sealed metal can. The can basically protects the sensor from noise, temperature and humidity. There is a tiny window made of IR-transmissive material to allow the IR signals to reach the sensor. Behind this window are 'two' balanced PIR sensors. In idle state, both sensors detect the same amount of IR radiation. When a warm body passes by, it first intercepts one of the two sensors, causing a positive differential change between the two halves. And then, when it leaves the sensing area, the reverse happens, and the sensor generates a negative differential change. When the pulse changes or in other words the PIR sensor detects motion, the output pin changes to "digital high" or 3.3V. The bottom bit consists of a bunch of circuitry. Few of them are of our interest. - Most PIR sensors have 3-pins VCC, GND and OUT. VCC and GND are to power the module (Operating voltage: DC 5V to 20V). The OUTPUT pin is the one which communicates with the micro-controller by sending digital pulse high (3.3v) when a motion is detected and digital low (0v) when no motion is detected. The pin-outs may vary between modules so always triple-check the pin-outs. - The BISS0001 or the "Micro Power PIR Motion Detector IC" gets the output from the sensor and after doing some minor processing it produces the digital output. - The module has two potentiometers one to adjust the sensitivity (which is up to 7m) and the other to adjust the time for which the output signal should stay high when an object is detected (it ranges from 0.3s to 5 mins). - There are 3 more pins on this module with a jumper between them to select the trigger modes. > 1st one is called "non-repeatable trigger" - this one goes low as soon as the delay time is over. > 2nd one is called "repeatable trigger" - it stays high as long as the object is in the proximity and will turn off once the object is gone and the delay is over. I will be using this mode for this project. If you want to do a quick test before going ahead with this tutorial please follow the steps below. A testing is also a good idea to test the range and duration of sensing. Step 4: Connecting Without Arduino - Connect the VCC to the +5v rail of the breadboard - Connect the GND to the -ve rail - Connect the LED along with a 220 ohm resistor to the OUT pin of the sensor Now, when the sensor detects a motion, the output pin will go "high" and the LED will light up. Move back and forward to find out the sensing the range. Then to test the duration walk in front of the sensor and then walk away and use a stopwatch to find out how long the LED stayed on. You can adjust the time or sensitivity by adjusting the POTs on the board. Step 5: Connecting With Arduino Now, to do the same with Arduino connect the VCC of the PIR sensor to the 5v pin of Arduino. Then connect the OUTput pin to D13 and GND to the Ground pin of the Arduino. Now, connect the LED along with a 220 ohm resistor to the D2 pin of the Arduino. Thats it, now you just need to upload the code and test if everything works the way it should. You can replace the LED with a Buzzer (to raise an alarm when an object is detected) or a Relay to drive a high voltage circuit. To learn more about relays please have a look at my tutorial Number 4 - "Driving a Relay with an Arduino". https://www.instructables.com/id/Driving-a-Relay-W... Step 6: Code The code is very simple * Start by defining the pin number 2 and 13 as LED pin and PIR pin respectively * Then we need to define the pin modes. LED pin to be the OUTPUT pin and PIR pin to be the INPUT pin * Next we need to read the value of the PIR pin and see if it is HIGH * If the value is HIGH, then turn ON the LED otherwise turn it OFF Step 7: Areas of Application of PIR Sensors PIR sensors can be used to: * Automate Opening and Closing of Doors * Automate All Outdoor Lights * Automate Lights of Basement, Garden or Covered Parking Areas * Automate Lift Lobby or Common Staircases Lights * Detect Presence of Human and Raise an Alarm * Create a Smart Home Automation & Security System, and many more.... Step 8: Demo So, this is my setup for the testing of the PIR sensor. The sensor is hooked up to the breadboard and is sitting on the table. As I am in front of the sensor the LED is on. Now, lets do a quick test. Currently, the sensor is in its idle state. I am going to walk in front of the it to activate the sensor. Tada, the LED just turned on after detecting my presence. The light stays on as long as I am in the sensors proximity. OK, lets walk away and start my stop watch to see if it turns off after 5 seconds. Success, everything worked the way I wanted. Thanks again for watching this video! I hope it helps you. If you want to support me, you can subscribe to my channel and watch my other videos. Thanks, ca again in my next video.
  21. DRIVING A RELAY WITH AN ARDUINO Hello everyone, welcome back to my channel. This is my 4th tutorial on how to drive a RELAY (not a relay module) with an Arduino. There are hundreds of tutorial available on how to use a "relay module" but I could not find a good one that shows how to use a Relay and not a Relay module. So, here we are to discuss how a relay works and how we can hook it up to an Arduino. Note: If you do any work with "mains power" such as 120v or 240v AC power wiring, you should always use proper equipments and safety gears and determine whether you have adequate skill and experience or consult a Licensed Electrician. This projects is not intended for use by children. Step 1: Basics A Relay is a large mechanical switch, which is toggled on or off by energizing a coil. Depending on the operating principle and structural features relays are of different types, such as: 1. Electromagnetic Relays 2. Solid State Relays 3. Thermal Relays 4. Power Varied Relays 5. Reed Relays 6. Hybrid Relays 7. Multi-dimensional Relays and so on, with varied ratings, sizes and applications. However, in this tutorial we will only be discussing about an electromagnetic relays. Guide to Different Types of Relays: 1. https://en.wikipedia.org/wiki/Relay 2. https://www.elprocus.com/different-types-of-relays... Step 2: My Relay (SRD-05VDC-SL-C) The relay I am looking at is a SRD-05VDC-SL-C. It is very popular relay among Arduino and DIY electronics hobbyists. This relay has 5 pins. 2 for the coil. Middle one is COM (common) and the rest of the two are called NO (Normally Open) and NC (Normally Close). When current flows through the coil of the relay, a magnetic field is created that causes a ferrous armature to move, either making or breaking an electrical connection. When the electromagnet is energized the NO is the one which is on and NC is the one which is off. When the coil is de-energized the electromagnetic force disappears and the armature moves back to the original position turning on the NC contact. The closing and releasing of the contacts results in powering on and off of the circuits. Now, if we look at the top of the relay the first thing we see is SONGLE, it is the name of the manufacturer. Then we see the "Current and Voltage Rating": it is the maximum current and/or voltage that can be passed through the switch. It starts from [email protected] and goes down till [email protected] Finally the bottom bit says: SRD-05VDC-SL-C SRD: is the model of relay. 05VDC: Also known as "Nominal Coil Voltage" or "Relay Activation Voltage", it is the voltage necessary for the coil to activate the relay. S: Stands for "Sealed Type" structure L: is the "Coil Sensitivity" which is 0.36W C: tells us about the contact form I have attached the datasheet of the relay for more information.http://old.ghielectronics.com/downloads/man/20084... Step 3: Getting Hands on a Relay Let’s start by determining the relay coil pins. You can do it either by connecting a multimeter to resistance measuring mode with a scale of 1000 ohm (since the coil resistance normally ranges between 50 ohm and 1000 ohm) or by using a battery. This relay has 'no' polarity marked on it since the internal suppressing diode is not present in it. Hence, the positive output of DC power supply can be connected to any one of the coil pins while negative output of DC power supply will be connected to the other pin of the coil or vice versa. If we connect our battery to the right pins you can actually hear the *clicking* sound when the switch turns on. If you ever get confused in figuring out which one is NO and which one is NC pin, follow the steps below to easily determine that: - Set the multimeter to resistance measuring mode. - Turn the relay upside-down to see pins located at its bottom part. - Now connect one on the multimeter's probe to the pin in between the coils (Common Pin) - Then connect the other probe one by one to the remaining 2 pins. Only one of the pins will complete the circuit and will show activity on the multimeter. Step 4: Arduino and a Relay * The question is "Why to use a relay with an Arduino?" A micro controller's GPIO (general purpose input/output) pins cannot handle higher power devices. A LED is easy enough, but large power items such as light bulbs, motors, pumps or fans required more sneaky circuitry. You can use a 5V relay to switch the 120-240V current and use the Arduino to control the relay. * A relay basically allows a relatively low voltage to easily control higher power circuits. A relay accomplishes this by using the 5V outputted from an Arduino pin to energize the electromagnet which in turn closes an internal, physical switch to turn on or off a higher power circuit. The switching contacts of a relay are completely isolated from the coil, and hence from the Arduino. The only link is by the magnetic field. This process is called "Electrical Isolation". * Now a question arises, Why do we need the extra bit of circuit to drive the relay? The coil of the relay needs a large current (around 150mA) to drive the relay, which an Arduino cannot provide. Therefore we need a device to amplify the current. In this project the NPN transistor 2N2222 drives the relay when the NPN junction gets saturated. Step 5: Hardware Requirement For this tutorial we need: 1 x Breadboard 1 x Arduino Nano/UNO (Whatever is handy) 1 x Relay 1 x 1K resistor 1 x 1N4007 High Voltage, High Current Rated Diode to protect the micro-controller from voltage spikes 1 x 2N2222 General purpose NPN transistor 1 x LED and a 220 ohm current limiting resistor to test the connectivity Few connecting cables A USB cable to upload the code to the Arduino and general soldering equipments Step 6: Assembly * Lets start by connecting the VIN and GND pins of the Arduino to the +ve and -ve rails of the breadboard. * Then connect one of the coils pin to the +ve 5v rail of breadboard. * Next we need to connect a diode across the electromagnetic coil. The diode across the electromagnet conducts in the reverse direction when the transistor is turned off to protect against a voltage spike or the backward flow of current. * Then connect the Collector of the NPN transistor to the 2nd pin of the coil. * The Emitter connects to the -ve rail of the breadboard. * Final, using a 1k resistor connect the Base of the transistor to the D2 pin of the Arduino. * Thats it our circuit is complete, now we can upload the code to the Arduino to turn on or off the relay. Basically, when +5v flow through the 1K resistor to the Base of transistor, a current of about .0005 amps (500 microamps) flows and turns on the transistor. A current of about .07 amps starts flowing through the junction turning on the electromagnet. The electromagnet then pulls the switching contact and moves it to connect the COM terminal to the NO terminal. * Once the NO terminal is connected a Lamp or any other load can be turned on. In this example I am just turning on and off a LED. Step 7: The Code The code is very simple. Just start by defining the digital pin number 2 of the Arduino as the Relay pin. Then define the pinMode as OUTPUT in the setup section of the code. Finally, in the loop section we are going to turn on and off the relay after every 500 CPU cycles by setting the Relay pin to HIGH and LOW respectively. Step 8: Conclusion * Remember: It is very important to place a diode across the coil of the relay because a spike of voltage (inductive kickback from the coil) is generated (Electromagnetic Interference) when the current is removed from the coil due to the collapse of the magnetic field. This voltage spike can damage the sensitive electronic components controlling the circuit. * Most Important: Same as capacitors, we always under-rate the relay to mitigate the risk of relay failures. Lets say, you need to work at [email protected], don’t use a relay rated for [email protected], instead use a bigger one such as [email protected] Remember, power = current * voltage so a [email protected] relay can handle up to a 6,000W device. * If you just replace the LED with any other electrical device like fan, bulb, fridge etc., you should be able to turn that appliance into a smart device with an Arduino controlled power outlet. * Relay can also be used to turn on or off two circuits. One when the electromagnet is on and the second one when the electromagnet is off. * A Relay helps in Electrical Isolation. The switching contacts of a relay are completely isolated from the coil, and hence from the Arduino. The only link is by the magnetic field. Note: Short circuits on Arduino pins, or attempting to run high current devices from it, can damage or destroy the output transistors in the pin, or damage the entire AtMega chip. Often this will result in a "dead" pin of the micro-controller but the remaining chip will still function adequately. For this reason it is a good idea to connect OUTPUT pins to other devices with 470Ω or 1k resistors, unless maximum current draw from the pins is required for a particular application Step 9: Thanks Thanks again for watching this video! I hope it helps you. If you want to support me, you can subscribe to my channel and watch my other videos. Thanks, ca again in my next video.
  22. Introduction ---------------- Hi Friends, I am back again with another Arduino based home automation project. This time I am trying to make my partner's life easy by installing a collision avoidance system in the garage to help her park the car safely without hitting the garage wall. So, in this video, I am going to use an ultrasonic sensor to calculate the car's distance from the garage wall and display it using green, yellow and red LEDs. The color of LEDs indicates whether to keep moving, slow down, stop or go back. The total cost of the project is around $20 - $25. Step 1: Logic The project has 3 phases Phase 1: Waiting for the car In this phase the device keeps looking for a moving object within the sensors proximity. If an object enters the proximity then one of the three LEDs turns on based on how far the moving object is. If the object is way too close, then a noise is made to make the moving object aware of the distance. Phase 2: No car in the garage If there is no object in the proximity then turn off all the LEDs. Phase 3: The car has stopped moving (Parked in the right spot) If the object has stopped moving and is still in the proximity wait for 20 CPU cycles and then turn off the LEDs. Step 2: Hardware Requirement For this very simple project we need: - A Perfboard - An Arduino nano/uno (whatever is handy) - A Red, Green and a Yellow LED (Light Emitting Diode) - 3 x 220ohm resistor for the LEDs - One HC-SRO4 Ultrasonic Sensor - A Buzzer shield or A buzzer and a 100 ohm resistor - A 220v AC to 5v DC Buck step-down module - One Female Pin Header Strip - An Ethernet cable - Some connecting cables - A USB cable to upload the code to the Arduino - and general soldering equipments Step 3: Assembly Let start by connecting the LEDs to the board. Connect the Red LED to pin D2, Yellow LED to D3 and the Green LED to D4 of the Arduino by putting in a 220ohm resistor between the Arduino board and the LEDs. Now lets connect the Buzzer to analogue pin A0. Next, connect the Trig pin of the Ultrasonic Sensor to D5 and the Echo pin to D6 of the Arduino. Once all the modules are connected to the Arduino board, its time for us to connect all the positive and negative pins together. Connect all the positive pins of the modules to the +5v supplied by the Buck Step-Down Module and the negative pins to the -ve terminal of the Module. That's it, we can now upload our sketch to the board. In this assembly I am using 3 LEDs to display the distance, however you can replace the 3 LEDs with a RGB LED, or you can also use an array of LEDs like an audio level indicator to display the movement of the car. Step 4: My Setup OK now lets see what I have made. I have installed the Arduino, buzzer, the ultrasonic sensor and the three 220 ohms resistors on one Perfboard. The 3 LEDs and the power module is installed on a second Perfboard. I will be covering the LEDs with a translucent cover to give it a nice look. The 220v power supply will be connected to the screw terminal block. The base unit will then be connected to the LEDs and the power supply with an Ethernet cable. Step 5: The Code int trigPin = PD5; // Sensor Trip pin connected to Arduino pin D5 int echoPin = PD6; // Sensor Echo pin connected to Arduino pin D6 int redLED = PD2; // Red LED connected to pin D2 int yellowLED = PD3; // Yellow LED connected to pin D3 int greenLED = PD4; // Green LED connected to pin D4 int buzzer = A0; // Buzzer connected to Analogue pin A0 long TempDistance = 0; // A variable to store the temporary distance int counter = 0; // Counter value to check if the object has stopped moving void setup() { Serial.begin(9600); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); pinMode(redLED, OUTPUT); pinMode(greenLED, OUTPUT); pinMode(yellowLED, OUTPUT); pinMode(buzzer, OUTPUT); } void loop() { long duration, Distance; digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); Distance = (duration/2) / 74; // Distance in Inches if(counter < 20){ // Do the rest if the car is still moving if (Distance > 200) { // Nothing in the garrage turnThemAllOff(); } if ((Distance > 55) && (Distance <= 200)) { // Turn on Green LED digitalWrite(greenLED, HIGH); digitalWrite(yellowLED, LOW); digitalWrite(redLED, LOW); noTone(buzzer); } if ((Distance > 15) && (Distance <= 55)) { // Turn on Yellow LED digitalWrite(yellowLED, HIGH); digitalWrite(redLED, LOW); digitalWrite(greenLED,LOW); noTone(buzzer); } if (Distance <= 15) { // Turn on Red LED digitalWrite(redLED, HIGH); digitalWrite(greenLED,LOW); digitalWrite(yellowLED, LOW); noTone(buzzer); } if (Distance < 8) { // Item is way to close - start the buzzer tone(buzzer, 500); } } if ((Distance == TempDistance) || ((Distance+1) == TempDistance) || ((Distance-1) == TempDistance)){ if(counter >= 20){ // Turn off the lights if the object hasn't moved for 20 cycles (no change in distance) Serial.println("No movement detected, turning off the lights"); turnThemAllOff(); } else { counter++; } } else { counter = 0; // Reset counter if there is a movement } TempDistance = Distance; Serial.print(Distance); Serial.println(" inches"); Serial.print("Counter : "); Serial.println(counter); delay(500); } // Function to turn the LEDs off void turnThemAllOff(){ digitalWrite(redLED, LOW); digitalWrite(greenLED,LOW); digitalWrite(yellowLED, LOW); noTone(buzzer); } Start the code by defining the constants and the global variables that will be used throughout the code. Then define the pin modes in the setup section of the code. Then create a function to turn off all the LEDs and the buzzer. Now, calculate the "Distance" in inches by reading the values received from the Ultrasonic Sensor. Then by checking the value of the "Distance" we will turn on and off the LEDs based on how far the object is. If the distance is greater than 200 then turn off all the LEDs and the buzzer as the object is out of range. Else if it is between 55 and 200 then turn on the green LED. If the object is between 15 and 55 then turn on the yellow LED, and if the object goes closer than 15 inches then turn on the red LED until it reaches 8 inches. When the distance becomes less than 8 start the buzzer along with the red LED. Next bit of the code is to set the value of the counter based on the cars movement which then decides when to turn off the LEDs. It compares the value of "Distance" with the "TempDistance" and if the values are same (object hasn't moved) then increments the counter. If the object moves any-time during this process the counter is reset to 0. Finally the "TempDistance" is set to the value of "Distance". Just before comparing the Distances we also need to check if the counter value has exceed 20. I am doing this to stop the below code from executing if the car is in a steady position. Lastly we just need to add a small delay to our sketch to pause the code for a while. Step 6: Quick Demo So this is how I have installed the unit in my garage. As I walk close to the sensor the light changes from green to yellow to red and ultimately the buzzer goes on when I am too close to the sensor. In my case I have installed the buzzer next to the Arduino however I will recommend you to install the buzzer along with the LEDs. If you want you can also flash the red LED when the buzzer goes on. So now, my partner can park the car easily without making any assumptions. Doesn't matter how many times she fail her driving test she is not going to break my wall (even when she is drunk). Not that I am asking her to drive when she is drunk (just kidding). Thanks again for watching this video! I hope it helps you. If you want to support me, you can subscribe to my channel and watch my other videos. Thanks, ca again in my next video.
  23. Introduction --------------- Hi Everyone, This is my 1st Arduino's tutorial video. In this video i am going to show you how to use a LDR or Light Dependent resistor to turn on and off another circuit or a LED. Wouldn’t it be really cool if whenever a room gets dark, a light bulb automatically turns ON and eliminates the darkness? In this very simple project, I am focusing on eliminating darkness. You can even use this as an emergency lighting system. Step 1: Principle The LDR is a special type of resistor which allows a lower voltage to pass through it (high resistance) whenever its dark and higher voltages to pass (low resistance) whenever there is a high intensity of light. We are going to use a 10k resistor along with the LDR to create a voltage divider circuit. The varying resistance of the LDR is converted to a varying voltage that the analog pin of the Arduino will then be using in its logic. Step 2: Harware Reqirement For this very simple DIY Arduino project we need: - a breadboard - an arduino uno/nano (whatever is handy) - LED (Light Emitting Diode) - LDR (Photoresistor) - A 10K Resistor for creating the voltage divider and a 220ohm resistor for the LED - Few breadboard friendly connecting wires - and a USB cable to upload the code to the Arduino Step 3: Assembly - Connect the 3.3v output of the Arduino to the positive rail of the breadboard - Connect the ground to the negative rail of the breadboard - Place the LDR on the breadboard - Attach the 10K resistor to one of the legs of the LDR - Connect the A0 pin of the Arduino to the same column where the LDR and resistor is connected (Since the LDR gives out an analog voltage, it is connected to the analog input pin on the Arduino. The Arduino, with its built-in ADC (Analog to Digital Converter), then converts the analog voltage from 0-5V into a digital value in the range of 0-1023). - Now connect the other end of the 10K resistor to the negative rail - And the the second (free) leg of the LDR to the positive rail Pretty much this is what we need for the light sensing. Basic circuits like this can be done without an Arduino aswell. However, if you want to log the values and use it to create charts, run other logics etc. I will recomend an Arduino or ESP8266 or may be a ESP32 for this. Now, as we want our circuit to do something in the real world other than just displaying the values on the computer screen we will be attaching a LED to the circuit. The LED will turn on when its dark and will go off when its bright. To achieve this we will: - Place the LED on the breadboard - Connect the 220ohm resistor to the long leg (+ve) of the LED - Then we will connect the other leg of the resistor to pin number 13 (digital pin) of the Arduino - and the shorter leg of the LED to the negative rail of the breadboard Step 4: The Code const int ledPin = 13; const int ldrPin = A0; void setup() { Serial.begin(9600); pinMode(ledPin, OUTPUT); pinMode(ldrPin, INPUT); } void loop() { int ldrStatus = analogRead(ldrPin); if (ldrStatus <= 200) { digitalWrite(ledPin, HIGH); Serial.print("Its DARK, Turn on the LED : "); Serial.println(ldrStatus); } else { digitalWrite(ledPin, LOW); Serial.print("Its BRIGHT, Turn off the LED : "); Serial.println(ldrStatus); } } Thanks again for watching this video! I hope it helps you. If you want to support me, you can subscribe to my channel and watch my other videos. Thanks, ca again in my next Instructable.
×
  • Create New...