Project #14: Components - Vibration - Mk21

Project #14: Components - Vibration - Mk21

Web

https://www.donluc.com/?p=4492

Facebook

https://www.facebook.com/share/v/16jnxhkpWK/

YouTube

https://youtu.be/gRjaEnON3ZE

Facebook

https://www.facebook.com/share/p/1EGVHFW6pE/

#DonLucElectronics #DonLuc #Vibration #DFRobot #Display #IoT #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

Mini Vibration Motor

Just as small as a fingernail, this 10*2.7mm mini vibration motor features a strong vibration, low noise, easy to embed, and long lifespan. Powered by voltage from 1.5V to 4.2V, it will vibrate once powered on, and the higher the voltage is, the faster the vibration frequency will be. It is widely applicable to projects like mobile phones, watches, facial massager, electric toys, etc.

DL2506Mk05

1 x DFRobot FireBeetle 2 ESP32-E
1 x Fermion: 3.5” 480x320 TFT LCD Capacitive Touchscreen
1 x GDL Line 10 CM
1 x Gravity: IO Shield for FireBeetle 2
1 x Terminal Block Board for FireBeetle 2 ESP32-E
1 x Mini Vibration Motor
1 x 1N4001 diode
1 x PN2222 Transistor
1 x 270 Ohm Resistor
1 x Lithium Ion Battery - 1000mAh
1 x Switch
1 x SPDT Slide Switch
1 x USB 3.1 Cable A to C

FireBeetle 2 ESP32-E

VIB - D7
DC - D2
CS - D6
RST - D3
VIN - +3.3V
GND - GND

DL2506Mk05p

DL2506Mk05p.ino

CODE
/****** Don Luc Electronics © ******
Project #14: Components - Vibration - Mk21
14-21
DL2506Mk05p.ino
DL2506Mk05
1 x DFRobot FireBeetle 2 ESP32-E
1 x Fermion: 3.5” 480x320 TFT LCD Capacitive Touchscreen
1 x GDL Line 10 CM
1 x Gravity: IO Shield for FireBeetle 2
1 x Terminal Block Board for FireBeetle 2 ESP32-E
1 x Mini Vibration Motor
1 x 1N4001 diode
1 x PN2222 Transistor
1 x 270 Ω Resistor
1 x Lithium Ion Battery - 1000mAh
1 x Switch
1 x SPDT Slide Switch
1 x USB 3.1 Cable A to C
*/

// Include the Library Code
// EEPROM Library to Read and Write EEPROM
// with Unique ID for Unit
#include "EEPROM.h"
// Arduino
#include <Arduino.h>
// DFRobot Display GDL API
#include <DFRobot_GDL.h>

// Vibrating
int iVibratingPin = D7;
// Speed 0 => 1500
int iSpeed = 0;

// Defined ESP32
#define TFT_DC  D2
#define TFT_CS  D6
#define TFT_RST D3

/*dc=*/ /*cs=*/ /*rst=*/
// DFRobot Display 320x480
DFRobot_ILI9488_320x480_HW_SPI screen(TFT_DC, TFT_CS, TFT_RST);

// EEPROM Unique ID Information
#define EEPROM_SIZE 64
String uid = "";

// Software Version Information
String sver = "14-21";

void loop() {

  // isVibrating
  isVibrating();
  
  // Display Vibration
  isDisplayVibration();
 
  delay(100);
  
}

getDisplay.ino

CODE
// DFRobot Display 3.5” 480x320
// DFRobot Display 3.5” 480x320 - UID
void isDisplayUID(){

  // DFRobot Display 240x320
  // Text Display
  // Text Wrap
  screen.setTextWrap(false);
  // Rotation
  screen.setRotation(3);
  // Fill Screen => black
  screen.fillScreen(0x0000);
  // Text Color => white
  screen.setTextColor(0xffff);
  // Font => Free Sans Bold 12pt
  screen.setFont(&FreeSansBold12pt7b);
  // TextSize => 1.5
  screen.setTextSize(1.5);
  // Don Luc Electronics
  screen.setCursor(0, 30);
  screen.println("Don Luc Electronics");
  // SD
  screen.setCursor(0, 60);
  screen.println("Vibration");
  // Version
  screen.setCursor(0, 90);
  screen.println("Version");
  screen.setCursor(0, 120);
  screen.println( sver );
  // EEPROM
  screen.setCursor(0, 150);
  screen.println("EEPROM");
  screen.setCursor(0, 180);
  screen.println( uid );

}
// Display Vibration
void isDisplayVibration(){

  // DFRobot Display 240x320
  // Text Display
  // Text Wrap
  screen.setTextWrap(false);
  // Rotation
  screen.setRotation(3);
  // Fill Screen => white
  screen.fillScreen(0xffff);
  // Text Color => blue
  screen.setTextColor(0x001F);
  // Font => Free Sans Bold 12pt
  screen.setFont(&FreeSansBold12pt7b);
  // TextSize => 1.5
  screen.setTextSize(1.5);
  // EMG
  screen.setCursor(0, 30);
  screen.println("Don Luc Electronics");
  // EMG Value
  screen.setCursor(0, 80);
  screen.println("Vibrating");

}

getEEPROM.ino

CODE
// EEPROM
// isUID EEPROM Unique ID
void isUID() {
  
  // Is Unit ID
  uid = "";
  for (int x = 0; x < 7; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getVibrating.ino

CODE
// Vibrating
// isVibrating
void isVibrating() {

    // Speed 0 => 1500
    iSpeed = 0;

    // Vibrating
    if (iSpeed >= 0 && iSpeed <= 1500)
    {
      
      analogWrite(iVibratingPin, iSpeed);
      
    }

}

setup.ino

CODE
// Setup
void setup()
{

  // Delay
  delay( 100 );
  
  // EEPROM Size
  EEPROM.begin(EEPROM_SIZE);
  
  // EEPROM Unique ID
  isUID();
  
  // Delay
  delay(100);

  // Vibrating Pin             
  pinMode(iVibratingPin, OUTPUT);

  // Delay
  delay(100);
  
  // DFRobot Display 3.5” 480x320
  screen.begin();

  // // DFRobot Display 3.5” 480x320
  // Don Luc Electronics
  // Vibrating
  // Version
  // EEPROM
  isDisplayUID();

  // Delay 5 Second
  delay( 5000 );

}
icon DL2506Mk05.zip 228KB Download(0)
License
All Rights
Reserved
licensBg
0