top of page

Search Results

163 results found with an empty search

  • APDS-9960 Gesture, Proximity, RGB color sensor module interface with Voice

    In this tutorial we will learn How to Use APDS9960 Gesture Sensor with Arduino nano and to display gesture hand directions, Proximity value and RGB color range on the LCD Display. In addition to that Voice announcement using DFPlayer mini for Gesture direction. Proximity sensing range from 0 to 255. Example: 0 - Very close 255 - Far RGB color sensing range 0 to 4097 as per Arduino APDS 9960 library. Circuit diagram Components Required Arduino Nano - 1 no APDS-9960 Gesture- 1no DFPlayer Mini - 1 no Memory card 16gb- 1 no Resistor 1k - 1 no APDS-9960 The APDS-9960 is a multipurpose sensor that can be used for Ambient Light, RGB Sensing, Proximity Sensing, and Gesture Detection. It has been used in Samsung’s Galaxy S5 earlier and is used in many mobile phones as a proximity sensor. It is also used in gesture robotics because of its advanced gesture detection technique enabling it to detect the gesture very accurately and with a very high speed. Pin Number Pin Name Description 1 VL Optional power to the IR LED if the PS jumper is not connected. Can be 3.0V to 4.5V. 2 GND Connected to the ground of the circuit used. 3 VCC Power supply to the board. Can be 2.4V to 3.6V. 4 SDA I2C Serial Data Address pin. Used to transfer the data through I2C. 5 SCL I2C Serial Clock Line pin. Provides clock pulse for I2C communication. 6 INT External Interrupt pin. It is Active LOW during interrupt event. APDS-9960 Features Ambient Light and RGB Sensing, Proximity Sensing, and Advance Gesture Detection. Operating Voltage: 2.4V to 3.6V. Operating current: 0.2mA. Communication protocol: 400KHz Highly sensitive Ambient and RGB sensing through UV and IR blocking filters. For gesture sensing there are four photodiodes, which are sensitive to different to next directions so that it can detect complex gestures easily. The APDS9960 is used in many places. We can use it for gesture detection, ambient and RGB light sensing, proximity sensing etc. It can be used to give the RGB ratings of the light, because many times we need a particular RGB rated light, so that can be manipulated accordingly. It is used in many phones to disable the screen while someone is dialing the phone and keeping it on ear. The sensor uses I2C communication protocol so that makes it super easy to use with microcontrollers. It operates on voltage range of 2.4V-3.6V (Typically 3.3V) and consumes really small current of 0.2mA so it is a power efficient sensor. The sensor gives the RGB values directly so you don’t need to do any calculations to fetch them. Hardware of this sensor module is very simple. APDS9960 sensor is the main component for this board. As the board operates on 3.3V so a voltage regulator is used. The sensor has four photodiodes to detect the gestures. Whenever a gesture is performed, the IR signal transmitted by the LED gets reflected by the obstacle and is detected by the photodiodes and then the information is received about velocity and distance. This is how a gesture is detected. For RGB color sensing it has different channels for each kind of light red, blue, green and clear. And each channel has IR and UV blocking filters and a data converter which produces 16-bit data for each channel. This sensing can be used to calculate color temperature and can also be used to manipulate the backlight of displays. The interrupt is used to control the detect function. So it triggers the sensor to release the IR or detect it according to the interrupt. There are two jumpers PS and I2C PU. These both jumpers are soldered by default. The PS jumper connects the power of the board to the power supply of the sensor. So if it is closed then we need to connect the VCC pin only to power the board as well as sensor. And if it is open then we need to provide the power to the board by VCC pin (2.4V to 3.6V) and to sensor by VL pin (3.0V to 4.5V). The I2C PU jumper connects the pull up resistors to SDA and SCL lines. By default it is soldered. If you wish to not use these pull up resistors then you need to de-solder it and open it. Applications Used in gesture robotics, LCD displays for manipulation of backlight. Used in cell phones as proximity sensor. Mechanical switch replacement. Can be used in RGB monitor. APDS-9960 module Datasheet Installing Library To install the library navigate to the Sketch > Include Library > Manage Libraries… Wait for Library Manager to download libraries index and update list of installed libraries. Arduino_APDS9960.h : you need to Download and install the Gesture library. DFRobotDFPlayerMini.h : you need to Download and install the MP3 player library. LiquidCrystal_I2C.h : you need to Download and install the LCD display library. After installing the required libraries, copy the following code to your Arduino IDE. Arduino code Subscribe and Download code #include #include LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 20 chars and 4 line display #include "Arduino.h" #include "SoftwareSerial.h" #include "DFRobotDFPlayerMini.h" SoftwareSerial mySoftwareSerial(10, 11); // RX, TX DFRobotDFPlayerMini myDFPlayer; void printDetail(uint8_t type, int value); void setup() { mySoftwareSerial.begin(9600); Serial.begin(9600); while (!Serial); // Wait for Serial Monitor to open if (!APDS.begin()) { Serial.println("Error initializing APDS-9960 sensor."); while (true); // Stop forever } lcd.init(); // initialize the lcd // Print a message to the LCD. lcd.backlight(); lcd.clear(); lcd.setCursor(6,0); lcd.print("APDS-9960"); lcd.setCursor(0,1); lcd.print("GESTURE: "); lcd.setCursor(0,2); lcd.print("PROXIMITY: "); lcd.setCursor(0,3); lcd.print("RGB: "); if (!myDFPlayer.begin(mySoftwareSerial, false)) { //Use softwareSerial to communicate with mp3. Serial.println(F("Unable to begin:")); Serial.println(F("1.Please recheck the connection!")); Serial.println(F("2.Please insert the SD card!")); while(true){ delay(0); // Code to compatible with ESP8266 watch dog. } } Serial.println(F("DFPlayer Mini online.")); myDFPlayer.volume(30); //Set volume value. From 0 to 30 myDFPlayer.play(5); //Play the 005.mp3 } int proximity = 0; int r = 0, g = 0, b = 0; unsigned long lastUpdate = 0; void loop() { // Check if a proximity reading is available. if (APDS.proximityAvailable()) { proximity = APDS.readProximity(); } // Check if a gesture reading is available if (APDS.gestureAvailable()) { int gesture = APDS.readGesture(); switch (gesture) { case GESTURE_UP: Serial.println("Detected UP gesture"); lcd.setCursor(9,1); lcd.print("UP "); myDFPlayer.play(2); //Play the 002.mp3 delay(3000); break; case GESTURE_DOWN: Serial.println("Detected DOWN gesture"); lcd.setCursor(9,1); lcd.print("DOWN "); myDFPlayer.play(1); //Play the 001.mp3 delay(3000); break; case GESTURE_LEFT: Serial.println("Detected LEFT gesture"); lcd.setCursor(9,1); lcd.print("LEFT "); myDFPlayer.play(3); //Play the 003.mp3 delay(3000); break; case GESTURE_RIGHT: Serial.println("Detected RIGHT gesture"); lcd.setCursor(9,1); lcd.print("RIGHT "); myDFPlayer.play(4); //Play 004.mp3 delay(3000); break; default: // Ignore break; } } // Check if a color reading is available if (APDS.colorAvailable()) { APDS.readColor(r, g, b); } // Print updates every 100 ms if (millis() - lastUpdate > 500) { lastUpdate = millis(); lcd.setCursor(11,2); lcd.print(proximity); lcd.setCursor(5,3); lcd.print(r); lcd.print(","); lcd.print(g); lcd.print(","); lcd.print(b); lcd.print(" "); } } Subscribe and Download code Demo Subscribe and Download code

  • Bluetooth Controlled RGB LED

    In this tutorial, you will learn about Arduino RGB LED control with Bluetooth. Here common cathode RGB LED and Bluetooth HC-05 used for interface. The android slider using to control for RGB values from 0 to 255 through An Android application. Circuit diagram Components Required Arduino Nano - 1 no Bluetooth module HC-05 - 1no RGB cc- 1 no Resistor 300E - 1no Bluetooth HC-05 Module HC-05 is a Bluetooth module which is designed for wireless communication. This module can be used in a master or slave configuration. Bluetooth serial modules allow all serial enabled devices to communicate with each other using Bluetooth. It has 6 pins, Key/EN- NC VCC to Connect 5 V power GND to power Ground TXD to Arduino Nano Rx (D0) RXD to Arduino Nano Tx (D1) State- NC HC-05 module Information HC-05 has red LED which indicates connection status, whether the Bluetooth is connected or not. Before connecting to HC-05 module this red LED blinks continuously in a periodic manner. When it gets connected to any other Bluetooth device, its blinking slows down to two seconds. This module works on 3.3 V. We can connect 5V supply voltage as well since the module has on board 5 to 3.3 V regulator. As HC-05 Bluetooth module has 3.3 V level for RX/TX and microcontroller can detect 3.3 V level, so, no need to shift transmit level of HC-05 module. But we need to shift the transmit voltage level from microcontroller to RX of HC-05 module. HC-05 Default Settings Default Bluetooth Name: “HC-05” Default Password: 1234 or 0000 Download Datasheet RGB LED A RGB LED is commonly used component in electronics, generally, as it is used for indication purpose. You can use RGB LED in various projects like portable flashlight, LED indicator, etc. An RGB LED can also be used for work according to condition like for condition 1st Red will glow, for condition 2nd green will glow and for condition 3rd blue will glow. Pin Configuration Pin No. Pin Name Description 1 R This terminal used for glowing LED in Red color 2 Gnd Common Cathode terminal (Ground) 3 G This terminal used for glowing LED in Green color 4 B This terminal used for glowing LED in Blue color Download Datasheet Installing the Arduino Library No need any special libraries. Arduino Code #include SoftwareSerial Bluetooth(10,11); // Rx,Tx pin to BT tx, rx pin char LED_CharRGB; // reads each character int RedPin = 5; // Red RGB pin -> D5 int GreenPin = 6; // Green RGB pin -> D6 int BluePin = 3; // Bluetoothe RGB pin -> D3 int RedValue = 255; // Red RGB pin -> D5 int GreenValue = 255; // Green RGB pin -> D6 int BlueValue = 255; // Bluetoothe RGB pin -> D3 String RedtempValue; String GreentempValue; String BluetempValue; char CurrentColor; void setup() { pinMode(RedPin,OUTPUT); pinMode(BluePin,OUTPUT); pinMode(GreenPin, OUTPUT); // initialize serial communication at 9600 bits per second: Serial.begin(9600); Bluetooth.begin(9600); } void loop() { //while is reading the message while(Bluetooth.available() > 0){ { LED_CharRGB = Bluetooth.read(); // Reads a character if(LED_CharRGB=='R'){ CurrentColor = 'R'; RedtempValue = ""; } else if(LED_CharRGB=='G'){ CurrentColor = 'G'; GreentempValue = ""; } else if(LED_CharRGB=='B'){ CurrentColor = 'B'; BluetempValue = ""; } if(CurrentColor == 'R' && LED_CharRGB!='R'){ RedtempValue += LED_CharRGB; } else if(CurrentColor == 'G' && LED_CharRGB!='G'){ GreentempValue += LED_CharRGB; } else if(CurrentColor == 'B' && LED_CharRGB!='B'){ BluetempValue += LED_CharRGB; } } Bluetooth.flush(); } analogWrite(RedPin, RedtempValue.toInt()); analogWrite(GreenPin, GreentempValue.toInt()); analogWrite(BluePin, BluetempValue.toInt()); } Subscribe and Download arduino code. ANDROID APPLICATION The Android app developers generally use JAVA language, but this Android app can also build without knowing the Java language. This app inventor is specially designed for Block programmers those who don’t know the JAVA language. Subscribe and Download android application. MIT main page MIT Block Demo Subscribe and Download arduino code. Subscribe and Download android application.

  • 4 channel Pulse Width Modulation with Bluetooth

    In this tutorial, LED Brightness Control using arduino PWM pins and Bluetooth HC-05 device for LED Brightness slider using android application. Here 4 PWM pins used to control 4 LEDs and 1 PWM pin for bluetooth communication of arduino nano. Circuit diagram Components Required Arduino Nano - 1 no Bluetooth module HC-05 - 1no LED 5mm/10mm - 4 nos Resistor 300E - 4 nos PWM Pulse Width Modulation, or PWM, is a technique for getting analog results with digital means. Digital control is used to create a square wave, a signal switched between on and off. This on-off pattern can simulate voltages in between the full Vcc of the board (e.g., 5 V on Uno, 3.3 V on a MKR board) and off (0 Volts) by changing the portion of the time the signal spends on versus the time that the signal spends off. The duration of "on time" is called the pulse width. To get varying analog values, you change, or modulate, that pulse width. If you repeat this on-off pattern fast enough with an LED for example, the result is as if the signal is a steady voltage between 0 and Vcc controlling the brightness of the LED. In the graphic, the green lines represent a regular time period. This duration or period is the inverse of the PWM frequency. In other words, with Arduino's PWM frequency at about 500Hz, the green lines would measure 2 milliseconds each. A call to analogWrite() is on a scale of 0 - 255, such that analogWrite(255) requests a 100% duty cycle (always on), and analogWrite(127) is a 50% duty cycle (on half the time) for example. Once you get this example running, grab your arduino and shake it back and forth. What you are doing here is essentially mapping time across the space. To our eyes, the movement blurs each LED blink into a line. As the LED fades in and out, those little lines will grow and shrink in length. Now you are seeing the pulse width. Bluetooth HC-05 Module HC-05 is a Bluetooth module which is designed for wireless communication. This module can be used in a master or slave configuration. Bluetooth serial modules allow all serial enabled devices to communicate with each other using Bluetooth. It has 6 pins, Key/EN- NC VCC to Connect 5 V power GND to power Ground TXD to Arduino Nano Rx (D0) RXD to Arduino Nano Tx (D1) State- NC HC-05 module Information HC-05 has red LED which indicates connection status, whether the Bluetooth is connected or not. Before connecting to HC-05 module this red LED blinks continuously in a periodic manner. When it gets connected to any other Bluetooth device, its blinking slows down to two seconds. This module works on 3.3 V. We can connect 5V supply voltage as well since the module has on board 5 to 3.3 V regulator. As HC-05 Bluetooth module has 3.3 V level for RX/TX and microcontroller can detect 3.3 V level, so, no need to shift transmit level of HC-05 module. But we need to shift the transmit voltage level from microcontroller to RX of HC-05 module. HC-05 Default Settings Default Bluetooth Name: “HC-05” Default Password: 1234 or 0000 Download Datasheet Installing the Arduino Library No need any special libraries. Arduino Code #include SoftwareSerial Bluetooth(10,11); // RX, TX int PWMLED1=3; int PWMLED2=5; int PWMLED3=6; int PWMLED4=9; void setup(){ pinMode(PWMLED1,OUTPUT); pinMode(PWMLED2,OUTPUT); pinMode(PWMLED3,OUTPUT); pinMode(PWMLED4,OUTPUT); Bluetooth.begin(9600); } void loop(){ if (Bluetooth.available()){ int value1=Bluetooth.parseInt(); int value2=Bluetooth.parseInt(); int value3=Bluetooth.parseInt(); int value4=Bluetooth.parseInt(); if (Bluetooth.read() =='\n'){ analogWrite(PWMLED1,value1); analogWrite(PWMLED2,value2); analogWrite(PWMLED3,value3); analogWrite(PWMLED4,value4); }} } Subscribe and Download arduino code. ANDROID APPLICATION The Android app developers generally use JAVA language, but this Android app can also build without knowing the Java language. This app inventor is specially designed for Block programmers those who don’t know the JAVA language. Subscribe and Download android application. MIT main page MIT Block Demo Subscribe and Download MIT APP .aia code download. Subscribe and Download arduino code. Subscribe and Download android application.

  • GPS Coordinates and GPS Clock

    In this project, we have shown how to interface a GPS neo6M module with Arduino nano, 20x4 LCD display. GPS (global positioning system) coordinates are usually expressed as the combination of latitude and longitude. The GPS coordinates data for longitude, latitude and GPS clock is displayed on the LCD. GPS Coordinates GPS coordinates are formed by two components that are a latitude , giving the north-south position, and a longitude, giving the east-west position. Use this map to convert any address in its GPS coordinates. You can also find the location of any GPS coordinates, and geocode its address if available. clock-Time Local time is the date/time reported by your PC (as seen by your web browser). If your PC clock is accurate to a second then the other time scales displayed above will also be accurate to within one second. UTC, Coordinated Universal Time, popularly known as GMT (Greenwich Mean Time), or Zulu time. Local time differs from UTC by the number of hours of your timezone. GPS clock, Global Positioning System time, is the atomic time scale implemented by the atomic clocks in the GPS ground control stations and the GPS satellites themselves. GPS time was zero at 0h 6-Jan-1980 and since it is not perturbed by leap seconds GPS is now ahead of UTC by 18 seconds. Loran-C, Long Range Navigation time, is an atomic time scale implemented by the atomic clocks in Loran-C chain transmitter sites. Loran time was zero at 0h 1-Jan-1958 and since it is not perturbed by leap seconds it is now ahead of UTC by 27 seconds. TAI, Temps Atomique International, is the international atomic time scale based on a continuous counting of the SI second. TAI is currently ahead of UTC by 37 seconds. TAI is always ahead of GPS by 19 seconds. Circuit Diagram Components Required Arduino Nano - 1 no LCD 20x4 with I²C module - 1no NEO6MV2 GPS Module - 1no NEO6MV2 GPS The NEO-6MV2 is a GPS (Global Positioning System) module and is used for navigation. The module simply checks its location on earth and provides output data which is longitude and latitude of its position.It is from a family of stand-alone GPS receivers featuring the high performance u-blox 6 positioning engine. These flexible and cost effective receivers offer numerous connectivity options in a miniature (16 x 12.2 x 2.4 mm) package. The compact architecture, power and memory options make NEO-6 modules ideal for battery operated mobile devices with very strict cost and space constraints. Its Innovative design gives NEO-6MV2 excellent navigation performance even in the most challenging environments. NEO-6MV2 GPS Module Pin Configuration The module has four output pins and we will describe the function each pin of them below. The powering of module and communication interface is done through these four pins. Pin Name Description VCC Positive power pin RX UART receive pin TX UART transmit pin GND Ground Features and Electrical Characteristics Standalone GPS receiver Anti-jamming technology UART Interface at the output pins (Can use SPI ,I2C and USB by soldering pins to the chip core) Under 1 second time-to-first-fix for hot and aided starts Receiver type: 50 Channels - GPS L1 frequency - SBAS (WAAS, EGNOS, MSAS, GAGAN) Time-To-First-fix: For Cold Start 32s, For Warm Start 23s, For Hot Start <1s Maximum navigation update rate: 5Hz Default baud rate: 9600bps EEPROM with battery backup Sensitivity: -160dBm Supply voltage: 3.6V Maximum DC current at any output: 10mA Operation limits: Gravity-4g, Altitude-50000m, Velocity-500m/s Operating temperature range: -40ºC TO 85°C Overview of the NEO-6MV2 GPS Module This module is one of popular GPS modules in the market and is also cheap to buy. The location data provided by it is accurate enough to satisfy most applications. And for it to be included in smart phones and tablets design points out its efficiency. This module is famous among hobbyist and engineers altogether who want to work on applications involving navigation. How to use the NEO-6MV2 GPS Module Getting this module to work is very easy. For the application circuit below we have connected the power to board and interfaced the output to the microcontroller UART to get it done. After circuitry, you need to set the baud rate of the controller matching the module, if it’s not matched you will get error. With baud rate setting done you can read the serial data directly from the module. This data will be longitude and latitude values and the user can play with them as desired. The raw values provided by the module are cumbersome to read directly and so a simple decimal calculation can be done in programming for getting easy to read values. Applications GPS application Smart phone and tablets Navigation systems Drones Hobby projects NEO-6MV2 GPS module Datasheet Installing Library To install the library navigate to the Sketch > Include Library > Manage Libraries… Wait for Library Manager to download libraries index and update list of installed libraries. TinyGPSPlus.h : you need to Download and install the GPS library. LiquidCrystal_I2C.h : you need to Download and install the LiquidCrystal_I2C library. After installing the required libraries, copy the following code to your Arduino IDE. Subscribe and Download code Arduino Code #include #include static const int RXPin = 4, TXPin = 3; static const uint32_t GPSBaud = 9600; // The TinyGPSPlus object TinyGPSPlus gps; // The serial connection to the GPS device SoftwareSerial ss(RXPin, TXPin); #include LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display void setup() { Serial.begin(115200); ss.begin(GPSBaud); lcd.init(); // initialize the lcd // Print a message to the LCD. lcd.backlight(); lcd.setCursor(0,0); lcd.print(" GPS LOCATION "); lcd.setCursor(0,1); lcd.print("LATITUDE, LONGITUDE"); lcd.setCursor(0,2); lcd.print("and GPS CLOCK "); delay(5000); lcd.clear(); } void loop() { // This sketch displays information every time a new sentence is correctly encoded. while (ss.available() > 0) if (gps.encode(ss.read())) displayInfo(); if (millis() > 5000 && gps.charsProcessed() < 10) { Serial.println(F("No GPS detected: check wiring.")); while(true); } } void displayInfo() { Serial.print(F("Location: ")); if (gps.location.isValid()) { lcd.setCursor(0,0); lcd.print("Latitude:"); lcd.setCursor(9,0); lcd.print(gps.location.lat(), 6); lcd.setCursor(0,1); lcd.print("Longitude:"); lcd.setCursor(10,1); lcd.print(gps.location.lng(), 6); } else { Serial.print(F("INVALID")); } Serial.print(F(" Date/Time: ")); if (gps.date.isValid()) { lcd.setCursor(0,2); lcd.print("Date:"); lcd.setCursor(6,2); lcd.print(gps.date.month()); lcd.print("/"); lcd.print(gps.date.day()); lcd.print(F("/")); lcd.print(gps.date.year()); } else { Serial.print(F("INVALID")); } Serial.print(F(" ")); lcd.setCursor(0,3); lcd.print("Time:"); if (gps.time.isValid()) { lcd.setCursor(6,3); if (gps.time.hour() < 10) lcd.print(F("0")); lcd.print(gps.time.hour()); lcd.print(F(":")); if (gps.time.minute() < 10) lcd.print(F("0")); lcd.print(gps.time.minute()); lcd.print(F(":")); if (gps.time.second() < 10) lcd.print(F("0")); lcd.print(gps.time.second()); } else { Serial.print(F("INVALID")); } Serial.println(); } Subscribe and Download code Demo Video Subscribe and Download code

  • Security Password Protected Door Access with EEPROM

    Here to learn How to Make an password protected Door Opening System Using Arduino, LCD, servo, Push button, LED and Matrix keypad. The Red LED using for Door opening indication and Push button used emergency bypass for secured password protected door opening in case of you forget the password. The password storing in Arduino EEPROM and you can change the password any time and values stored in EEPROM. When the power of the Arduino the EEPROM remember the previously stored password. Circuit Diagram Components Required Arduino Nano - 1 no LCD 16x2 with I²C module - 1no 4x4 Matrix keypad - 1no Red LED - 1 no Servo mini SG90 - 1 no Push Button - 1no 10k resistor- 1no Servo motor A servo motor is an electric device used for precise control of angular rotation. It is used in applications that demand precise control over motion, like in case of control of a robotic arm. The rotation angle of the servo motor is controlled by applying a PWM signal to it. By varying the width of the PWM signal, we can change the rotation angle and direction of the motor. Wire Configuration: Brown - Ground wire connected to the ground of system Red - Powers the motor typically +5V is used Orange - PWM signal is given in through this wire to drive the motor Servo SG90 Data Sheet 4x4 keypad module 4x4 keypad will have eight terminals. In them four are rows of matrix and four are columns of matrix. These 8 pins are driven out from 16 buttons present in the module. Those 16 alphanumeric digits on the module surface are the 16 buttons arranged in matrix formation. Using keypad module is little tricky. As 16 keys are connected in matrix formation the module is a little complex to use. The module gives only 8 pins as a way for interacting with 16 buttons. We are going to explain how to use the keypad module in a simple way step by step: Consider we have connected the keypad module to a microcontroller. Step1: first set all rows to output and set them at +5v. Next set all columns as input to sense the high logic. Now consider a button is pressed on keypad. And that key is at 2nd column and 3rd row. With the button being pressed the current flows as shown in figure. With that a voltage of +5v appears at terminal c2. Since the column pins are set as inputs, the controller can sense c2 going high. The controller can be programmed to remember that c2 going high and the button pressed is in c2 column. Step2: next set all columns to output and set them at +5v. Next set all rows as input to sense the high logic. Since the key pressed is at 2nd column and 3rd row. The current flows as shown below. With that current flow a positive voltage of +5v appears at r3 pin. Since all rows are set as inputs, the controller can sense +5v at r3 pin. The controller can be programmed to remember the key being pressed at third row of keypad matrix. From previous step, we have known the column number of key pressed and now we know row number. With that we can match the key being pressed. We can take the key input provided by this way for 4x4 keypad module. 4x4 keypad module Datasheet Installing Library To install the library navigate to the Sketch > Include Library > Manage Libraries… Wait for Library Manager to download libraries index and update list of installed libraries. Keypad.h : you need to Download and install the keypad library. LiquidCrystal_I2C.h : you need to Download and install the LiquidCrystal_I2C library. After installing the required libraries, copy the following code to your Arduino IDE. Arduino Code #include #include #include LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display #include Servo myservo; #define LEDindicator A3 //Door Open/close LED indicator #define BypassSwitch A2 //Push Button for emergency bypass int pos = 0; // variable to store the servo position const byte numRows= 4; //number of rows on the keypad const byte numCols= 4; //number of columns on the keypad char keymap[numRows][numCols]= { {'1', '2', '3', 'A'}, {'4', '5', '6', 'B'}, {'7', '8', '9', 'C'}, {'*', '0', '#', 'D'} }; char keypressed; char code[]= {'1','2','3','4'}; //The default password char code_buff1[sizeof(code)]; //Where the new password is stored char code_buff2[sizeof(code)]; //Where the new password is stored again short a=0,i=0,s=0,j=0; //Variables byte rowPins[numRows] = {8,9,10,11}; //Rows 0 to 3 byte colPins[numCols]= {2,3,4,5}; //Columns 0 to 3 Keypad myKeypad= Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols); void setup() { Serial.begin(9600); lcd.init(); // initialize the lcd // Print a message to the LCD. lcd.backlight(); lcd.setCursor(0,0); lcd.print("ACCESS PROTECTED"); lcd.setCursor(0,1); lcd.print("ENTER *(PW)0 "); myservo.attach(7); // attaches the servo on pin 9 to the servo object pinMode(LEDindicator,OUTPUT); pinMode(BypassSwitch,INPUT); for(i=0 ; i= 90; pos -= 1) { // goes from 180 degrees to 0 degrees myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15 ms for the servo to reach the position } // delay(3000); //Opens for 3s you can change digitalWrite(LEDindicator,LOW); lcd.clear(); lcd.setCursor(0,0); lcd.print("ACCESS PROTECTED"); lcd.setCursor(0,1); lcd.print("ENTER *(PW)0 "); } } void GetCode(){ //Getting code sequence i=0; //All variables set to 0 a=0; j=0; while(keypressed != '0'){ //The user press 0 to confirm the code otherwise he can keep typing keypressed = myKeypad.getKey(); if(keypressed != NO_KEY && keypressed != '0' ){ //If the char typed isn't 0 and neither "nothing" lcd.setCursor(j,1); //This to write "*" on the LCD whenever a key is pressed it's position is controlled by j lcd.print("*"); j++; if(keypressed == code[i]&& i= 90; pos -= 1) { // goes from 180 degrees to 0 degrees myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15 ms for the servo to reach the position } digitalWrite(LEDindicator,LOW); } Subscribe and Download code with EEPROM Demo Video Subscribe and Download code in case of forget password to erase EEPROM values in address (without EEPROM).

  • Bluetooth Controlled Door Lock/Unlock with EEPROM

    Here to learn How to Make an Bluetooth controlled Door Opening and closing System Using Arduino, LCD, servo, LED and android application. The Servo Motor to control door open and close through bluetooth using android application. The Red/Green (Bi colour) LED using for Door Lock/Unlock indication and LCD display 16x2 using for Door open/close status. The Door locked/unlocked information number storing in Arduino EEPROM at every time of door Open/close. When the power of the Arduino the EEPROM remember the previously stored number and maintaining the door lock/unlock status. Circuit Diagram Components Required Arduino Nano - 1 no Bluetooth module HC-05 - 1no Bi color LED (CA) - 1 no Servo mini SG90 - 1 no Servo motor A servo motor is an electric device used for precise control of angular rotation. It is used in applications that demand precise control over motion, like in case of control of a robotic arm. The rotation angle of the servo motor is controlled by applying a PWM signal to it. By varying the width of the PWM signal, we can change the rotation angle and direction of the motor. Wire Configuration: Brown - Ground wire connected to the ground of system Red - Powers the motor typically +5V is used Orange - PWM signal is given in through this wire to drive the motor Servo SG90 Data Sheet Bluetooth HC-05 Module HC-05 is a Bluetooth module which is designed for wireless communication. This module can be used in a master or slave configuration. Bluetooth serial modules allow all serial enabled devices to communicate with each other using Bluetooth. It has 6 pins, 1.Key/EN: It is used to bring Bluetooth module in AT commands mode. If Key/EN pin is set to high, then this module will work in command mode. Otherwise by default it is in data mode. The default baud rate of HC-05 in command mode is 38400bps and 9600 in data mode. HC-05 module has two modes, Data mode: Exchange of data between devices. Command mode: It uses AT commands which are used to change setting of HC-05. To send these commands to module serial (USART) port is used. 2. VCC: Connect 5 V or 3.3 V to this Pin. 3. GND: Ground Pin of module. 4. TXD: Transmit Serial data (wirelessly received data by Bluetooth module transmitted out serially on TXD pin) 5. RXD: Receive data serially (received data will be transmitted wirelessly by Bluetooth module). 6. State: It tells whether module is connected or not. HC-05 module Information HC-05 has red LED which indicates connection status, whether the Bluetooth is connected or not. Before connecting to HC-05 module this red LED blinks continuously in a periodic manner. When it gets connected to any other Bluetooth device, its blinking slows down to two seconds. This module works on 3.3 V. We can connect 5V supply voltage as well since the module has on board 5 to 3.3 V regulator. As HC-05 Bluetooth module has 3.3 V level for RX/TX and microcontroller can detect 3.3 V level, so, no need to shift transmit level of HC-05 module. But we need to shift the transmit voltage level from microcontroller to RX of HC-05 module. HC-05 Default Settings Default Bluetooth Name: “HC-05” Default Password: 1234 or 0000 Default Communication: Slave Default Mode: Data Mode Data Mode Baud Rate: 9600, 8, N, 1 Command Mode Baud Rate: 38400, 8, N, 1 Default firmware: LINVOR Download datasheet Installing Library To install the library navigate to the Sketch > Include Library > Manage Libraries… Wait for Library Manager to download libraries index and update list of installed libraries. LiquidCrystal_I2C.h : you need to Download and install the LiquidCrystal_I2C library. After installing the required libraries, copy the following code to your Arduino IDE. Arduino Code #include #include Servo myservo; #include LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display int RedLED = 4; int GreenLED = 5; void setup() { Serial.begin(9600); pinMode(RedLED, OUTPUT); pinMode(GreenLED, OUTPUT); pinMode(RedLED, HIGH); pinMode(GreenLED, HIGH); lcd.init(); // initialize the lcd // Print a message to the LCD. lcd.backlight(); // setup code here myservo.attach(7); if(EEPROM.read(0) == 1) // Reads the EEPROM value stored. { myservo.write(90); // Rotates the servo to 90 for lock delay(200); } else if(EEPROM.read(0) == 2)// Reads the EEPROM value stored. { myservo.write(180); // Rotates the servo to 180 for open delay(200); } lcd.setCursor(0,0); lcd.print("BLUETOOTH ACCESS"); } void loop() { // put your main code here, to run repeatedly: if(Serial.available() > 0) { char data; data = Serial.read(); // The variable data is used to store the value sent by the Android app switch(data) { case '1': if(EEPROM.read(0) == 1) { EEPROM.write(0, 2); // Writes the number 2 to address 0 on the EEPROM. Serial.println((EEPROM.read(0))); for(int a = 90; a <= 180; a++) // Rotates the servo to the unlocked position { pinMode(RedLED, LOW); pinMode(GreenLED, HIGH); myservo.write(a); delay(15); lcd.setCursor(0,1); lcd.print("DOOR OPEN "); } } else if(EEPROM.read(0) == 2) { EEPROM.write(0, 1); // Writes the number 1 to address 0 on the EEPROM. Serial.println((EEPROM.read(0))); for(int x = 180; x >= 90; x--) // Rotates the servo to the locked position { pinMode(RedLED, HIGH); pinMode(GreenLED, LOW); myservo.write(x); delay(15); lcd.setCursor(0,1); lcd.print("DOOR CLOSED"); } } break; } } } Subscribe and Download code. Demo: Android application First open Mobile application and select Bluetooth image button, after that select Bluetooth HC-05 device to connect and enter Password as mentioned above (0000 or 1234). Subscribe and Download code.

  • IR Remote Controlled 4 channel relay

    In this Project TSOP1738 IR receiver to control a relay board using Arduino nano and LCD. The LCD to display the relay ON/OFF status of 4 channel relay board. The relay module is used to automate them the electrical appliances. Components required TSOP 1738 IR receiver - 1no Arduino Nano - 1 no LCD1602 with I²C - 1no IR remote (HM23) - 1no 4 Channel Relay Module (HW316)- 1no Circuit diagram 4 Channel Relay Module The four-channel relay module contains four 5V relays and the associated switching and isolating components, which makes interfacing with a microcontroller or sensor easy with minimum components and connections. The contacts on each relay are specified for 250VAC and 30VDC and 10A in each case, as marked on the body of the relays. Internal circuit Each relay on the board has the same circuit, and the input ground is common to all four channels. The driver circuit for this relay module is slightly different compared to traditional relay driving circuits since there is an optional additional layer of isolation. When the jumper is shorted, the relay and the input share the same VCC, and when it is open, a separate power supply must be provided to the JD-VCC jumper to power the relay coil and optocoupler output. The inputs for this module are active low, meaning that the relay is activated when the signal on the input header is low. This is because the indicator LED and the input of the optocoupler are connected in series to the VCC pin on one end, so the other end must be connected to the ground to enable the current flow. The optocouplers used here are the PCF817, which is a common optocoupler and can also be found in through-hole packaging. How To Use The Four-Channel Relay Module The four-channel can be used to switch multiple loads at the same time since there are four relays on the same module. This is useful in creating a central hub from where multiple remote loads can be powered. It is useful for tasks like home automation where the module can be placed in the main switchboard and can be connected to loads in other parts of the house and can be controlled from a central location using a microcontroller. In this diagram, four separate loads (represented by lightbulbs) have been connected to the NO terminals of the relay. The live wire has been connected to the common terminal of each relay. When the relays are activated, the load is connected to the live wire and is powered. This setup can be reversed by connecting the load to the NC terminal that keeps it powered on till the relay is activated. Download DATASHEET TSOP1738(SM0038) The TSOP sensor has the ability to read the output signals from home remotes like TV remote, Home theatre remote, AC remote etc. All these remotes will work with a frequency of 38kHz and this IC can pick up any IR signals process them and provide the output on pin 3. So if you are looking for a sensor to analyse, re-create or duplicate the functions of a remote then this IC will be the perfect choice for you. Also keep in mind that this series TSOP-1738 will receive only 38Khz IR signals. All remotes in India will operate in 38Khz, kindly ensure if it is the same in your country. The TSOP-1738 is an IR Receiver Sensor, which can be used to receive IR signals of 38Khz. The sensor operates on 5V and consumes around 5mA to operate. Normally the signal pin (pin 3) IC is connected to a microcontroller to analyse the IR signal received. Installing Library Infrared receiver: you need to download and install the IR library. LiquidCrystal_I2C.h : you need to Download and install the LiquidCrystal_I2C library. Follow the next steps to install those libraries. In your Arduino IDE, to install the libraries go to Sketch > Include Library > Add .ZIP library… and select the library you’ve just downloaded. After installing the required libraries, copy the following code to your Arduino IDE. Refer IR decoder project for IR remote code .https://www.dofbot.com/post/ir-decoder-with-data-acquisition-tool Arduino Code #include int IRPIN = 2; IRrecv irrecv(IRPIN); decode_results results; #include LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display int Relay1 = 6; //Relay1 int Relay2 = 7; //Relay2 int Relay3 = 8; //Relay3 int Relay4 = 9; //Relay4 int LED = 13; //LED indiacator int STATE1 = 0; //Indicates state of Relay1 (OFFboard LED) int STATE2 =0; //Indicates state of Relay2 (OFFboard LED) int STATE3 = 0; //Indicates state of Relay3 (OFFboard LED) int STATE4 =0; //Indicates state of Relay4 (OFFboard LED) int STATE5 =0; //Indicates state of Relay1 to 5 (OFFboard LED) void setup() { Serial.begin(9600); Serial.println("Enabling IRin"); irrecv.enableIRIn(); //Starts receiving Serial.println("Enabled IRin"); pinMode(Relay1, OUTPUT); pinMode(Relay2, OUTPUT); pinMode(Relay3, OUTPUT); pinMode(Relay4, OUTPUT); pinMode(Relay1, HIGH); //Turns Relay1 OFFby default pinMode(Relay2, HIGH); //Turns Relay2 OFFby default pinMode(Relay3, HIGH); //Turns Relay3 OFFby default pinMode(Relay4, HIGH); //Turns Relay4 OFFby default pinMode(LED, OUTPUT); lcd.init(); // initialize the lcd // Print a message to the LCD. lcd.backlight(); lcd.setCursor(0,0); lcd.print(" INFRARED HOME "); lcd.setCursor(0,1); lcd.print("AUTOMATION"); delay(1000); lcd.clear(); lcd.setCursor(0,0); lcd.print("RL1 RL2 RL3 RL4"); lcd.setCursor(0,1); lcd.print("ON ON ON ON "); } void loop() { if(irrecv.decode(&results)) { digitalWrite(LED, HIGH); //turn LED ON delay(250); digitalWrite(LED, LOW); //turn LED OFF Serial.println(results.value, HEX); irrecv.resume(); if(results.value==0x1FE50AF) // IR code case1 { if(STATE1 == 0) //If state is 0, relay 1 OFF { digitalWrite(Relay1, HIGH); //turn OFF Relay1 STATE1 = 1; lcd.setCursor(0,1); lcd.print("OFF"); } else if(STATE1 == 1) //If state is 1, relay 1 ON { digitalWrite(Relay1,LOW); //turn ON Relay1 STATE1 = 0; lcd.setCursor(0,1); lcd.print("ON "); } } if(results.value==0x1FED827) // IR code case2 { if(STATE2 == 0) //If state is 0, relay 2 OFF { digitalWrite(Relay2, HIGH); //turn OFF Relay2 STATE2 = 1; lcd.setCursor(4,1); lcd.print("OFF"); } else if(STATE2 == 1) //If state is 1, relay 2 ON { digitalWrite(Relay2,LOW); //turn ON Relay2 STATE2 = 0; lcd.setCursor(4,1); lcd.print("ON "); } } if(results.value==0x1FEF807) // IR code case3 { if(STATE3 == 0) //If state is 0, relay 3 OFF { digitalWrite(Relay3, HIGH); //turn OFF Relay3 STATE3 = 1; lcd.setCursor(8,1); lcd.print("OFF"); } else if(STATE3 == 1) //If state is 1, relay 3 ON { digitalWrite(Relay3,LOW); //turn ON Relay3 STATE3 = 0; lcd.setCursor(8,1); lcd.print("ON "); } } if(results.value==0x1FE30CF) // IR code case3 { if(STATE4 == 0) //If state is 0, relay 4 OFF { digitalWrite(Relay4, HIGH); //turn OFF Relay4 STATE4 = 1; lcd.setCursor(12,1); lcd.print("OFF"); } else if(STATE4 == 1) //If state is 1, relay 4 ON { digitalWrite(Relay4,LOW); //turn ON Relay4 STATE4 = 0; lcd.setCursor(12,1); lcd.print("ON "); } } irrecv.resume(); //Ready to receive next data } } Subscribe and Download code. Serial monitor After a successful upload, open the Serial Monitor at a baud rate of 9600. see the IR decoder received code result on Serial monitor. Demo

  • IR Decoder with Data Acquisition tool

    Here to learn TSOP1738 IR receiver to build an IR Remote Decoder using Arduino nano and LCD. The LCD to display the decoded code – the number for pressed button on IR remote. The hex code for every button will be logged to Microsoft Excel Sheet from the PLX-DAQ release 2. Components required TSOP 1738 IR receiver - 1no Arduino Nano - 1 no LCD1602 with I²C - 1no Circuit diagram TSOP1738(SM0038) The TSOP sensor has the ability to read the output signals from home remotes like TV remote, Home theatre remote, AC remote etc. All these remotes will work with a frequency of 38kHz and this IC can pick up any IR signals process them and provide the output on pin 3. So if you are looking for a sensor to analyse, re-create or duplicate the functions of a remote then this IC will be the perfect choice for you. Also keep in mind that this series TSOP-1738 will receive only 38Khz IR signals. All remotes in India will operate in 38Khz, kindly ensure if it is the same in your country. The TSOP-1738 is an IR Receiver Sensor, which can be used to receive IR signals of 38Khz. The sensor operates on 5V and consumes around 5mA to operate. Normally the signal pin (pin 3) IC is connected to a microcontroller to analyse the IR signal received. TSOP1738 Pin Configuration Pin Number Pin Name Description 1 Ground Connected to the Ground of circuit 2 Vcc Typically connect to +5V, maximum of 6V can be given 3 Signal The signal pin gives out the sequence based on the IR signal detected Download DATASHEET PLX-DAQ PLX-DAQ is a Parallax microcontroller data acquisition add-on tool for Microsoft Excel and acquires up to 26 channels of data from any Parallax microcontrollers and drops the numbers into columns as they arrive. PLX-DAQ provides easy spreadsheet analysis of data collected in the field, laboratory analysis of sensors and real-time equipment monitoring. Any of microcontrollers connected to any sensor and the serial port of a PC can now send data directly into Excel. PLX-DAQ has the following features: Plot or graph data as it arrives in real-time using Microsoft Excel Record up to 26 columns of data Mark data with real-time (hh:mm:ss) or seconds since reset Read/Write any cell on a worksheet Read/Set any of 4 checkboxes on control the interface Example code for the BS2, SX (SX/B) and Propeller available Baud rates up to 128K Supports Com1-15 Download PLX-DAQ Installing Library Infrared receiver: you need to download and install the IR library. LiquidCrystal_I2C.h : you need to Download and install the LiquidCrystal_I2C library. Follow the next steps to install those libraries. In your Arduino IDE, to install the libraries go to Sketch > Include Library > Add .ZIP library… and select the library you’ve just downloaded. After installing the required libraries, copy the following code to your Arduino IDE. Arduino Code #include int IRPIN = 2; IRrecv irrecv(IRPIN); decode_results result; int RemoteButton = 0; #include LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display void setup() { Serial.begin(9600); Serial.println("Enabling IRin"); irrecv.enableIRIn(); Serial.println("Enabled IRin"); Initialize_streamer(); lcd.init(); // initialize the lcd // Print a message to the LCD. lcd.backlight(); lcd.setCursor(0,0); lcd.print("INFRARED DECODER"); } void loop() { if (irrecv.decode(&result)) { RemoteButton = RemoteButton+1; Serial.print("Value: "); Serial.println(result.value, HEX); lcd.setCursor(0,1); lcd.print("Received: "); lcd.setCursor(9,1); lcd.print(result.value, HEX); Write_streamer(); irrecv.resume(); } delay(500); } void Initialize_streamer() { Serial.println("CLEARDATA"); //clears up any data left from previous projects Serial.println("LABEL,Hex Code, RemoteButton"); //always write LABEL, to indicate it as first line } void Write_streamer() { Serial.print("DATA"); //always write "DATA" to Indicate the following as Data Serial.print(","); //Move to next column using a "," Serial.print(result.value, HEX); //Store date on Excel Serial.print(","); //Move to next column using a "," Serial.print(RemoteButton); //Store date on Excel Serial.print(","); //Move to next column using a "," Serial.println(); //End of Row move to next row } Subscribe and Download code. Now open the ‘PLX-DAQ spreadsheet’ file from the Desktop/Laptop. If macros are disabled on your Excel, then Click on Options->Enable the content -> Finish -> OK to Enable the Macros. Subscribe and Download PLX-DAQ . Subscribe and Download EXCEL Demo

  • 9999second timer using Rotary encoder

    In this tutorial we will see how to create a adjustable timer using rotary encoder and buzzer for Timer end with the Arduino board and the TM1637 display. Components required Arduino Nano - 1 no TM1637 module - 1 no Toggle switch - 1 no 5V/3.3V Power module - 1 no Buzzer - 1 no Circuit diagram TM1637 TM1637 seven segment modules is a ready made multiplexed seven segment display with 4 digits. The driver IC is TM1637; It has 4pin control there are GND, VCC, DIO, CLK. only two signal lines can make MCU control four Digit 7-segments LED can be used to display decimal, letters and so on. The 7segment LED Display has common anode type. TM1637 4-Digit 7-Segment Display Specifications Operating voltage 3.3 – 5 V Current draw-80 mA Operating temperature-10 – 80 °C Interfacing TM1637 with the arduino: So the first thing you want to do is connect the clock pin to any pin on the Arduino. CLK clock pin of the TM1637 with the digital pin 3 of the arduno. DIO pin of the TM1637 with digital pin 2 of the arduino. VCC of the TM1637 with the 3.3V of the Power module. Gnd of the TM1637 with the ground of the Power module. Installing Library 7segment: you need to Download and install the TM1637 library. Follow the next steps to install those libraries. In your Arduino IDE, to install the libraries go to Sketch > Include Library > Add .ZIP library… and select the library you’ve just downloaded. After installing the required libraries, copy the following code to your Arduino IDE. Refer Counter project for testing of TM1637 module. https://www.dofbot.com/post/up-down-counter-using-7segment-display Arduino Code // include libraries #include #include // Module connection pins (Digital Pins) #define CLK 2 #define DIO 3 TM1637Display display(CLK, DIO); byte D1=0;// seconds s byte D2=0;// Second x 10 byte D3=0;// Second x 100 byte D4=0;// Second x 1000 int counter=0; int n=0; #define Toggle 5 //Toggle Switch D5 #define Buzzer 9 // Buzzer #define RotSW 11 // Rotary Encoder #define RotdtB 12 //Rotary Encoder "B" #define RotclkA 10 //Rotary Encoder "A" void setup() { pinMode(Toggle, INPUT_PULLUP);//Toggle Switch pinMode(RotclkA, INPUT_PULLUP);//Rotary Encoder CLK pinMode(RotSW, INPUT_PULLUP);// Rotary Encoder SW pinMode(RotdtB, INPUT_PULLUP);//Rotary Encoder DT pinMode(Buzzer,OUTPUT );//Buzzer display.setBrightness(7); display.showNumberDec(0, true); delay(1000); display.clear(); delay(1000); display.showNumberDec(0, true); digitalWrite((Buzzer), HIGH); delay(1000); digitalWrite((Buzzer), LOW); } void loop() { // set timer // set s. do{ D1= SCounter(); //display.clear(); display.showNumberDec(D1); //Display the n value; delay(250); }while(digitalRead(RotSW)==HIGH);//Push to Rotary delay(250); counter=0; // set Second x 10 display.showNumberDec(D1,true,2,2);//Display D1 do{ D2= SCounter(); n=D2*10+D1; //display.clear(); display.showNumberDec(n , true,2,2); //Display the n value; delay(250); }while(digitalRead(RotSW)==HIGH);//Push to Rotary delay(250); counter=0; // set Second x 100 do{ D3= SCounter(); n=D3*100+D2*10+D1; //display.clear(); display.showNumberDec(n , true, 3, 1); //Display the n value; delay(250); }while(digitalRead(RotSW)==HIGH);//Push to Rotary delay(250); counter=0; // set Second x 1000 do{ D4= SCounter(); n=D4*1000+D3*100+D2*10+D1; //display.clear(); display.showNumberDec(n , true, 4,0); //Display the n value; delay(250); }while(digitalRead(RotSW)==HIGH);//Push to Rotary delay(250); counter=0; //Out of set routine n=D4*1000+D3*100+D2*10+D1;//compute "n" if(n!=0){ do{//Repeat set value n=D4*1000+D3*100+D2*10+D1;//compute "n" //display set "n" display.showNumberDec(n); while(0==digitalRead(RotSW));//Push Rotary to start while(1==digitalRead(RotSW)); delay(50); do{// decrease time //display current "n" display.showNumberDec(n); while(millis() % 1000 != 0);//time base, 1second n=n-1; }while(n!=0); display.showNumberDec(n);//display n=0 digitalWrite(Buzzer,HIGH);// start beep delay(1000); digitalWrite(Buzzer,LOW); // stop beep }while(digitalRead(Toggle)==LOW);//"Toggle" to GND D1=0; D2=0; D3=0; D4=0; } } byte SCounter(){ // Rotary encoder routine while(digitalRead(RotSW) &digitalRead(RotdtB) & digitalRead(RotclkA)==1); if(digitalRead(RotSW)==0){ return counter; } switch(digitalRead(RotclkA)) { case HIGH: while(digitalRead(RotclkA)==0); while(digitalRead(RotdtB)==0); counter ++; counter=counter%10; break; case LOW: while(digitalRead(RotdtB)==0); while(digitalRead(RotclkA)==0); counter --; if(counter==-1){ counter=9;//left begin with 9 } counter=abs(counter)%10; break; } return counter; } Subscribe and Download code. Demo:

  • Simple Kitchen timer using 7segment display & Arduino

    In this tutorial we will see how to create a Timer start, UP/Down setting using push button and buzzer for Timer end with the Arduino board and the TM1637 display Components required Arduino Nano - 1 no TM1637 module - 1 no Push Button switch - 3 no 5V/3.3V Power module - 1 no Buzzer - 1 no Circuit diagram TM1637 TM1637 seven segment modules is a ready made multiplexed seven segment display with 4 digits. The driver IC is TM1637; It has 4pin control there are GND, VCC, DIO, CLK. only two signal lines can make MCU control four Digit 7-segments LED can be used to display decimal, letters and so on. The 7segment LED Display has common anode type. TM1637 4-Digit 7-Segment Display Specifications Operating voltage 3.3 – 5 V Current draw-80 mA Operating temperature-10 – 80 °C Interfacing TM1637 with the arduino: So the first thing you want to do is connect the clock pin to any pin on the Arduino. CLK clock pin of the TM1637 with the digital pin 3 of the arduno. DIO pin of the TM1637 with digital pin 2 of the arduino. VCC of the TM1637 with the 3.3V of the Power module. Gnd of the TM1637 with the ground of the Power module. Installing Library 7segment: you need to Download and install the TM1637 library. Follow the next steps to install those libraries. In your Arduino IDE, to install the libraries go to Sketch > Include Library > Add .ZIP library… and select the library you’ve just downloaded. After installing the required libraries, copy the following code to your Arduino IDE. Refer Counter project for testing of TM1637 module. https://www.dofbot.com/post/up-down-counter-using-7segment-display Arduino Code #include // Define the connections pins for display #define CLK 2 #define DIO 3 // Define other pin connections #define UP_BUTTON 8 #define DOWN_BUTTON 9 #define START_BUTTON 4 #define BUZZER 5 int duration; // Duration in seconds // Create display object of type TM1637Display: TM1637Display display = TM1637Display(CLK, DIO); // Set the individual segments for the word displays: const uint8_t seg_end[] = { SEG_A | SEG_D | SEG_E | SEG_F | SEG_G, // E SEG_C | SEG_E | SEG_G, // n SEG_B | SEG_C | SEG_D | SEG_E | SEG_G, // d 0x00 // All off }; const uint8_t seg_go[] = { SEG_A | SEG_C | SEG_D | SEG_F | SEG_G, // s SEG_D | SEG_E | SEG_F | SEG_G, // t 0x00, // All off 0x00 // All off }; void setup() { pinMode(UP_BUTTON, INPUT_PULLUP); pinMode(DOWN_BUTTON, INPUT_PULLUP); pinMode(START_BUTTON, INPUT_PULLUP); pinMode(BUZZER, OUTPUT); duration = 10; // Default to 10 seconds display.setBrightness(5); // 0 to 7 change if required ShowTime(duration); } void loop() { // Function will checks for time change buttons and only return // when start button pressed WaitForStart(); // Start the duration timer TimeDuration(); } void WaitForStart(){ // Check for button presses every 0.15 seconds while (digitalRead(START_BUTTON) == HIGH){ // Check if up or down has been pressed //if time > 60 then increment by 10 seconds if (digitalRead(UP_BUTTON) == LOW){ if (duration < 60){ duration++; } else{ duration += 10; } ShowTime(duration); } if (digitalRead(DOWN_BUTTON) == LOW){ if (duration > 60){ duration -= 10; } else{ duration--; } ShowTime(duration); } delay(150); } // Start button has been pressed tone(BUZZER, 1500, 100); display.clear(); display.setSegments(seg_go); } void TimeDuration(){ // While loop will continue until time up unsigned long startTime = millis(); unsigned long timer = 1000ul * duration; // Repeatedly check if time is up while ((millis() - startTime) <= timer){ // Calculate time elapsed in seconds int elapsed = int((millis() - startTime)/1000); // Only start to display countdown after 3 seconds if ((millis() - startTime) > 3000){ ShowTime(duration - elapsed); } } // Time up tone(BUZZER, 500, 5000); display.clear(); display.setSegments(seg_end); // Wait 5 seconds and reset display delay(5000); // Show duration for next player ShowTime(duration); } void ShowTime(int value){ static int lastTime; // Update the display if time has changed if (lastTime != value) { lastTime = value; int iMinutes = value / 60; int iSeconds = value - (iMinutes * 60); // Show on 4 digit display uint16_t number = iMinutes * 100 + iSeconds; display.showNumberDecEx(number, 0b01000000, true, 4, 0); } } Subscribe and Download code. Demo

  • UP/DOWN counter using 7segment Display

    In this tutorial, you will learn how you can test TM1637 4-digit 7-segment display and Counter function with adjusting time delay. Components required Arduino Nano - 1 no TM1637 module - 1 no Push Button switch - 2 no 5V/3.3V Power module - 1 no Circuit diagram TM1637 TM1637 seven segment modules is a ready made multiplexed seven segment display with 4 digits. The driver IC is TM1637; It has 4pin control there are GND, VCC, DIO, CLK. only two signal lines can make MCU control four Digit 7-segments LED can be used to display decimal, letters and so on. The 7segment LED Display has common anode type. TM1637 4-Digit 7-Segment Display Specifications Operating voltage 3.3 – 5 V Current draw-80 mA Operating temperature-10 – 80 °C Interfacing TM1637 with the arduino: So the first thing you want to do is connect the clock pin to any pin on the Arduino. CLK clock pin of the TM1637 with the digital pin 3 of the arduno. DIO pin of the TM1637 with digital pin 2 of the arduino. VCC of the TM1637 with the 5V of the arduino. Gnd of the TM1637 with the ground of the arduino. Counter In this example we use the TM1637 display module to make a simple counter with two push buttons. The setup is as shown below where the buttons are connected to pin 8 and 9 of Arduino nano. This example shows the commonest basic functions of the TM1637Display.h library which are; setBrightness(): for setting the brightness of the display. There are seven levels of brightness therefore the value can be in 0x0a to 0x0f. showNumberDec(): this is the most used function and it is for displaying decimal number digits. This function can take four arguments that is, showNumberDec (int num, bool leading_zero, uint8_t length, uint8_t pos), the first argument is the number to be displayed, the second is determining leading zeros and can either be true or false, the third argument is the number of digits to be displayed and the last argument is for selecting the position where the number to be displayed should begin from. For example display.showNumberDec(25,false,2,1) displays the number 25 without leading zeros on the second and third digit Installing Library 7segment: you need to Download and install the TM1637 library. Follow the next steps to install those libraries. In your Arduino IDE, to install the libraries go to Sketch > Include Library > Add .ZIP library… and select the library you’ve just downloaded. After installing the required libraries, copy the following code to your Arduino IDE. Arduino Code First testing the TM1637 display check. #include #include // Module connection pins (Digital Pins) #define CLK 2 #define DIO 3 // The amount of time (in milliseconds) between tests #define TEST_DELAY 500 const uint8_t SEG_DONE[] = { SEG_B | SEG_C | SEG_D | SEG_E | SEG_G, // d SEG_D | SEG_C | SEG_F | SEG_E | SEG_G, // b SEG_C | SEG_D | SEG_E | SEG_G, // O SEG_D | SEG_E | SEG_F | SEG_G, // t }; TM1637Display display(CLK, DIO); void setup() { } void loop() { int k; uint8_t data[] = { 0xff, 0xff, 0xff, 0xff }; uint8_t blank[] = { 0x00, 0x00, 0x00, 0x00 }; display.setBrightness(0x0f); // All segments on display.setSegments(data); delay(TEST_DELAY); // Selectively set different digits data[0] = display.encodeDigit(0); data[1] = display.encodeDigit(1); data[2] = display.encodeDigit(2); data[3] = display.encodeDigit(3); display.setSegments(data); delay(TEST_DELAY); /* for(k = 3; k >= 0; k--) { display.setSegments(data, 1, k); delay(TEST_DELAY); } */ display.clear(); display.setSegments(data+2, 2, 2); delay(TEST_DELAY); display.clear(); display.setSegments(data+2, 2, 1); delay(TEST_DELAY); display.clear(); display.setSegments(data+1, 3, 1); delay(TEST_DELAY); // Show decimal numbers with/without leading zeros display.showNumberDec(0, false); // Expect: ___0 delay(TEST_DELAY); display.showNumberDec(0, true); // Expect: 0000 delay(TEST_DELAY); display.showNumberDec(1, false); // Expect: ___1 delay(TEST_DELAY); display.showNumberDec(1, true); // Expect: 0001 delay(TEST_DELAY); display.showNumberDec(301, false); // Expect: _301 delay(TEST_DELAY); display.showNumberDec(301, true); // Expect: 0301 delay(TEST_DELAY); display.clear(); display.showNumberDec(14, false, 2, 1); // Expect: _14_ delay(TEST_DELAY); display.clear(); display.showNumberDec(4, true, 2, 2); // Expect: __04 delay(TEST_DELAY); display.showNumberDec(-1, false); // Expect: __-1 delay(TEST_DELAY); display.showNumberDec(-12); // Expect: _-12 delay(TEST_DELAY); display.showNumberDec(-999); // Expect: -999 delay(TEST_DELAY); display.clear(); display.showNumberDec(-5, false, 3, 0); // Expect: _-5_ delay(TEST_DELAY); display.showNumberHexEx(0xf1af); // Expect: f1Af delay(TEST_DELAY); display.showNumberHexEx(0x2c); // Expect: __2C delay(TEST_DELAY); display.showNumberHexEx(0xd1, 0, true); // Expect: 00d1 delay(TEST_DELAY); display.clear(); display.showNumberHexEx(0xd1, 0, true, 2); // Expect: d1__ delay(TEST_DELAY); // Run through all the dots for(k=0; k <= 4; k++) { display.showNumberDecEx(0, (0x80 >> k), true); delay(TEST_DELAY); } // Brightness Test for(k = 0; k < 4; k++) data[k] = 0xff; for(k = 0; k < 7; k++) { display.setBrightness(k); display.setSegments(data); delay(TEST_DELAY); } // On/Off test for(k = 0; k < 4; k++) { display.setBrightness(7, false); // Turn off display.setSegments(data); delay(TEST_DELAY); display.setBrightness(7, true); // Turn on display.setSegments(data); delay(TEST_DELAY); } // Done! display.setSegments(SEG_DONE); while(1); } Subscribe and Download code. Next UP/DOWN Counter code #include #define UP 8 #define DOWN 9 const int CLK = 2; //Set the CLK pin connection to the display const int DIO = 3; //Set the DIO pin connection to the display const uint8_t blank[] = {0x00, 0x00, 0x00,0x00}; TM1637Display display(CLK, DIO); //set up the 4-Digit Display. int num = 0; // The amount of time (in milliseconds) between counter #define COUNTER_DELAY 1000 void setup() { pinMode(UP, INPUT_PULLUP); pinMode(DOWN, INPUT_PULLUP); display.setBrightness(0x0f); //set the diplay to brightness display.setSegments(blank);//clear display } void loop() { display.showNumberDec(num, true, 4, 0); delay(COUNTER_DELAY); if( digitalRead(UP) ) { // if the UP button is presses num++; // increment 'num' if(num > 9999) num = 0; } if( digitalRead(DOWN) ) { // if the DOWN button is presses num--; // decrement 'num' if(num < 0) num = 9999; } } Subscribe and Download code. Demo

  • Temperature indicator using 7segment display & Arduino Nano

    In this tutorial, you will learn how you can test TM1637 4-digit 7-segment displays with Arduino and Temperature sensor DHT11 interface. Components required Arduino Nano - 1 no TM1637 module - 1 no DHT 11 - 1 no 5V/3.3V Power module - 1 no Circuit diagram TM1637 TM1637 seven segment modules is a ready made multiplexed seven segment display with 4 digits. The driver IC is TM1637; It has 4pin control there are GND, VCC, DIO, CLK. only two signal lines can make MCU control four Digit 7-segments LED can be used to display decimal, letters and so on. The 7segment LED Display has common anode type. TM1637 4-Digit 7-Segment Display Specifications Operating voltage 3.3 – 5 V Current draw-80 mA Operating temperature-10 – 80 °C Interfacing TM1637 with the arduino: So the first thing you want to do is connect the clock pin to any pin on the Arduino. CLK clock pin of the TM1637 with the digital pin 3 of the arduno. DIO pin of the TM1637 with digital pin 2 of the arduino. VCC of the TM1637 with the 5V of the arduino. Gnd of the TM1637 with the ground of the arduino. DHT11 Connecting DHT11/DHT22/AM2302 sensor to Arduino nano is fairly simple. Connect VCC pin on the sensor to the 3.3V pin on the Arduino nano and ground to ground. Also connect Data pin on the sensor to D5 pin of the Arduino nano. Installing Library 7segment: you need to Download and install the TM1637 library. Temperature sensor: you need to Download and install the DHT11 library. Follow the next steps to install those libraries. In your Arduino IDE, to install the libraries go to Sketch > Include Library > Add .ZIP library… and select the library you’ve just downloaded. After installing the required libraries, copy the following code to your Arduino IDE. Arduino Code First testing the TM1637 display check. #include #include // Module connection pins (Digital Pins) #define CLK 2 #define DIO 3 // The amount of time (in milliseconds) between tests #define TEST_DELAY 500 const uint8_t SEG_DONE[] = { SEG_B | SEG_C | SEG_D | SEG_E | SEG_G, // d SEG_D | SEG_C | SEG_F | SEG_E | SEG_G, // b SEG_C | SEG_D | SEG_E | SEG_G, // O SEG_D | SEG_E | SEG_F | SEG_G, // t }; TM1637Display display(CLK, DIO); void setup() { } void loop() { int k; uint8_t data[] = { 0xff, 0xff, 0xff, 0xff }; uint8_t blank[] = { 0x00, 0x00, 0x00, 0x00 }; display.setBrightness(0x0f); // All segments on display.setSegments(data); delay(TEST_DELAY); // Selectively set different digits data[0] = display.encodeDigit(0); data[1] = display.encodeDigit(1); data[2] = display.encodeDigit(2); data[3] = display.encodeDigit(3); display.setSegments(data); delay(TEST_DELAY); /* for(k = 3; k >= 0; k--) { display.setSegments(data, 1, k); delay(TEST_DELAY); } */ display.clear(); display.setSegments(data+2, 2, 2); delay(TEST_DELAY); display.clear(); display.setSegments(data+2, 2, 1); delay(TEST_DELAY); display.clear(); display.setSegments(data+1, 3, 1); delay(TEST_DELAY); // Show decimal numbers with/without leading zeros display.showNumberDec(0, false); // Expect: ___0 delay(TEST_DELAY); display.showNumberDec(0, true); // Expect: 0000 delay(TEST_DELAY); display.showNumberDec(1, false); // Expect: ___1 delay(TEST_DELAY); display.showNumberDec(1, true); // Expect: 0001 delay(TEST_DELAY); display.showNumberDec(301, false); // Expect: _301 delay(TEST_DELAY); display.showNumberDec(301, true); // Expect: 0301 delay(TEST_DELAY); display.clear(); display.showNumberDec(14, false, 2, 1); // Expect: _14_ delay(TEST_DELAY); display.clear(); display.showNumberDec(4, true, 2, 2); // Expect: __04 delay(TEST_DELAY); display.showNumberDec(-1, false); // Expect: __-1 delay(TEST_DELAY); display.showNumberDec(-12); // Expect: _-12 delay(TEST_DELAY); display.showNumberDec(-999); // Expect: -999 delay(TEST_DELAY); display.clear(); display.showNumberDec(-5, false, 3, 0); // Expect: _-5_ delay(TEST_DELAY); display.showNumberHexEx(0xf1af); // Expect: f1Af delay(TEST_DELAY); display.showNumberHexEx(0x2c); // Expect: __2C delay(TEST_DELAY); display.showNumberHexEx(0xd1, 0, true); // Expect: 00d1 delay(TEST_DELAY); display.clear(); display.showNumberHexEx(0xd1, 0, true, 2); // Expect: d1__ delay(TEST_DELAY); // Run through all the dots for(k=0; k <= 4; k++) { display.showNumberDecEx(0, (0x80 >> k), true); delay(TEST_DELAY); } // Brightness Test for(k = 0; k < 4; k++) data[k] = 0xff; for(k = 0; k < 7; k++) { display.setBrightness(k); display.setSegments(data); delay(TEST_DELAY); } // On/Off test for(k = 0; k < 4; k++) { display.setBrightness(7, false); // Turn off display.setSegments(data); delay(TEST_DELAY); display.setBrightness(7, true); // Turn on display.setSegments(data); delay(TEST_DELAY); } // Done! display.setSegments(SEG_DONE); while(1); } Subscribe and Download code. Next Temperature indication // Include the libraries #include #include #include // Define the connections pins #define CLK 2 #define DIO 3 #define DHTPIN 5 // Create variable int temperature_celsius; int temperature_fahrenheit; // Create °C symbol const uint8_t celsius[] = { SEG_A | SEG_B | SEG_F | SEG_G, // Circle SEG_A | SEG_D | SEG_E | SEG_F // C }; // Create °F symbol const uint8_t fahrenheit[] = { SEG_A | SEG_B | SEG_F | SEG_G, // Circle SEG_A | SEG_E | SEG_F | SEG_G // F }; #define DHTTYPE DHT11 // DHT 11 //#define DHTTYPE DHT22 // DHT 22 (AM2302) // Create display object of type TM1637Display TM1637Display display = TM1637Display(CLK, DIO); // Create dht object of type DHT: DHT dht = DHT(DHTPIN, DHTTYPE); void setup() { // Set the display brightness (0-7) display.setBrightness(5); // Clear the display display.clear(); // Setup sensor dht.begin(); } void loop() { // Read the temperature as Celsius and Fahrenheit temperature_celsius = dht.readTemperature(); temperature_fahrenheit = dht.readTemperature(true); // Display the temperature in celsius format display.showNumberDec(temperature_celsius, false, 2, 0); display.setSegments(celsius, 2, 2); delay(1000); // Display the temperature in fahrenheit format display.showNumberDec(temperature_fahrenheit, false, 2, 0); display.setSegments(fahrenheit, 2, 2); delay(1000); } Subscribe and Download code. Demo

bottom of page