Home > Control Circuits >Other Control Circuitss > How to Build a Gesture-Controlled Elevator Prototype Using Arduino Nano

How to Build a Gesture-Controlled Elevator Prototype Using Arduino Nano

Source: InternetPublisher:通通 Keywords: Contactless Arduino Gesture Control Updated: 2024/12/19

    During this time of the coronavirus pandemic, elevators have become high-risk places where everyone touches the same buttons. In many places, people have discovered tricks to prevent touching elevator buttons, such as using tissue paper, toothpicks, or toilet paper to press elevator buttons.

    So, in continuation of our previous Corona safety projects like Automatic Sanitizer Machine, Contactless Temperature Monitoring, and Social Distance Detector, we will here build a Gesture Controlled Elevator Prototype using Arduino Nano.

    This contactless lift uses Arduino Nano, APDS9960 gesture sensor and OLED display module. With this gesture based control panel, you can easily control your Lift by gestures. APDS9960 sensor is used to read gestures. UP and DOWN gestures are used to set the floor number, the left gesture closes the lift door and moves the lift according to the floor number, and the right gesture is used to open the door.

    Required Components

    Arduino Nano

    OLED display module

    APDS9960 RGB & Gesture Sensor

    Breadboard

    Jumper Wires

    APDS9960 RGB & Gesture Sensor

    The APDS9960 RGB and Gesture Detection Module is a small breakout board with a built-in APDS-9960 sensor, UV and IR blocking filters, four independent diodes sensitive to different directions, and an I2C compatible interface. The sensor can be used for ambient light and color measurement, proximity detection, and contactless gesture sensing. It has a gesture detection range of 10 to 20 cm and can be used to control microcontrollers, robots, and many other projects.

pYYBAGLwziCAYdftAAOvngC9cOE434.png

    feature:

    Operating voltage: 2.4V to 3.6V

    Operating Range: 4-8 inches (10-20 cm).

    I2C interface (I2C address: 0x39).

    Ambient light and RGB color sensing, proximity

Sensing and gesture detection in optical modules

    I2C-bus Fast-mode compatible interface with data rates up to 400 kHz.

Circuit Schematic

    Given below is the circuit diagram of contactless elevator using APDS9960.

poYBAGLwzheAKhmrAAGvC5XUUSE248.png

    We are connecting Arduino Nano with APDS9960 Sensor and OLED Display. The VCC and GND pins of APDS9960 Sensor and OLED Display are connected to 3.3V and GND of Arduino. And the SCL and SDA pins of APDS9960 Sensor and OLED Display are connected to A5 and A4 pins of Arduino respectively.

poYBAGLwzhKAXmaXAAANrDDMOK4176.png

    This is what a complete setup for gesture-controlled elevators using Arduino looks like:

poYBAGLwzg6AQj29AAUGBpH2HO8348.png

    Code Description

    The complete code for the Contactless Elevator using APDS9960 is given at the end of the page. Here, we will explain some important parts of the code. In this program, we will use APDS9960 and Adafruit_SH1106 library. The APDS9960 library can be downloaded from the Arduino IDE. To download the library, go to Sketch > Library Manager > Search and type Arduino APDS9960. And the Adafruit_SH1106 library can be downloaded from here.

    So start the code as usual by including all the required libraries. Adafruit_SH1106.h is a modified version of the original Adafruit library.

#include

    In the next few lines, variables are defined to store the current floor and floor number that the user wants to go to.

Integer number of floors = 0;
int currentFloor = 0;

    After that, input the bitmaps of the up arrow, down arrow, open door, and closed door images. You can use a converter like Image2cpp to generate the HEX code of the image. To learn more about how to use Image2cpp, follow this Arduino QR code generator tutorial.

const unsigned char up [] PROGMEM = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,………………………………………… ………………………………………………..
};
const unsigned char down [] PROGMEM = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,………………………………………… ………………………………………………..
};
const unsigned char dooropen [] PROGMEM = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xc0, 0x1f, 0xff, 0xff, 0xe0, ,…………………………………………………… …………………………………………………..
};

    In the setup() function, the serial monitor is initialized for debugging at a baud rate of 9600. Then in the next few lines, the OLED display and the APDS9960 sensor are initialized using the begin() method as shown below:

SerialNumber.Start(9600);
  if (!APDS.begin()) {
    Serial.println("Error initializing APDS9960 sensor!");
  }
Serial.println("Detect gesture...");
  display.begin(SH1106_SWITCHCAPVCC, 0x3C);

    After initializing the display and sensors, clear the display buffer using the clearDisplay() method and set the font size and color using the display.setTextSize() and display.setTextColor() methods.

  display.setTextSize(2);
  display.setTextColor(white);
  display.clearDisplay();
  display.show();

    Inside the void loop(), keep checking if any gesture is made. If yes, read the gesture value and check which gesture it is (up, down, right, left) and print the corresponding reading on the serial monitor. The UP and DOWN gestures are used to set the floor the user wants to go to. The left gesture is to close the elevator door and move the elevator according to the floor number, while the right gesture is used to open the door.

if (APDS.gestureAv

    The home1() function is used to draw the elevator's home page display. This includes the up arrow, down arrow, door open, door closed signs, and the current floor number. The drawBitmap() function is used to draw images on the OLED display. The syntax of the drawBitmap() function is as follows:

drawBitmap(int16_t x, int16_t y, bitmap, int16_t w, int16_t h, colour);

    Where:

    int16_t x, int16_t y are the X and Y coordinates of the OLED display

    bitmap is the name of the bitmap

    int16_t w, int16_t h are the height and weight of the image.

Invalid home1()
{
  display.setCu

    The start() function is used to move the elevator up or down. To do this, the current floor number is compared with the floor number the user wants to go to. If the floor number is greater than the current floor number. If the floor number is less than the current floor number, the elevator will move up. Then the elevator will move down. The elevator will stop when both the current floor number and the floor number. are the same.

void begin()
{
      while (floor number > current floor) {
      Serial.println("Up");
      Current Floor++;
      display.drawBitmap(0, 0, up, 100, 64, WHITE);
      display.setCursor(101,23);
      display.println(curren

    Testing a gesture-controlled touchless lift

Once the hardware and code are ready, connect the Arduino Nano to the laptop and upload the complete code given below. As you can see, by default the OLED will display the elevator user interface.

pYYBAGLwzgSADGv8AAF3bxpwxOQ749.png

    Now wave your hand up or down as shown in the video below to set the floor you want to go to. Then make a left gesture to confirm the elevator to that floor. If you want to stop the elevator, make a right gesture with your hand.

    #include

    #include

    #include

    #include

    #define OLED_RESET -1

    Adafruit_SH1106 Display (OLED_RESET);

    Integer number of floors = 0;

    int currentFloor = 0;

    //Paste your bitmap here

    const unsigned char up [] PROGMEM = {

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x03, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x0f, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xf0,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xfc, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x03, 0xff, 0xc7, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x07, 0xff, 0x81, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xfe, 0x00,

    0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x00, 0x3f, 0xf8, 0x00,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf0, 0x00, 0x1f, 0xfe, 0x00, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x01, 0xff, 0xe0, 0x00, 0x07, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x07, 0xff, 0x80, 0x00, 0x03, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0x00,

    0x00, 0x00, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x00, 0x00, 0x00, 0x7f,

    0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xf8, 0x00, 0x00, 0x00, 0x1f, 0xfc, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x01, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x0f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x03, 0xff, 0xc0, 0x00, 0x38, 0x00, 0x03, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0x00,

    0x00, 0x7c, 0x00, 0x01, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xfe, 0x00, 0x01, 0xff, 0x00,

    0x00, 0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xf8, 0x00, 0x03, 0xff, 0x80, 0x00, 0x3f, 0xfc,

    0x00, 0x00, 0x00, 0x00, 0xff, 0xf0, 0x00, 0x0f, 0xff, 0xe0, 0x00, 0x0f, 0xfe, 0x00, 0x00, 0x00,

    0x03, 0xff, 0xc0, 0x00, 0x1f, 0xff, 0xf0, 0x00, 0x07, 0xff, 0x80, 0x00, 0x00, 0x07, 0xff, 0x80,

    0x00, 0x7f, 0xff, 0xfc, 0x00, 0x01, 0xff, 0xc0, 0x00, 0x00, 0x1f, 0xfe, 0x00, 0x00, 0xff, 0xff,

    0xfe, 0x00, 0x00, 0xff, 0xf0, 0x00, 0x00, 0x3f, 0xfc, 0x00, 0x03, 0xff, 0xc7, 0xff, 0x80, 0x00,

    0x3f, 0xf8, 0x00, 0x00, 0xff, 0xf0, 0x00, 0x07, 0xff, 0x81, 0xff, 0xc0, 0x00, 0x1f, 0xfe, 0x00,

    0x01, 0xff, 0xe0, 0x00, 0x1f, 0xfe, 0x00, 0xff, 0xf0, 0x00, 0x07, 0xff, 0x00, 0x07, 0xff, 0x80,

    0x00, 0x3f, 0xfc, 0x00, 0x3f, 0xf8, 0x00, 0x03, 0xff, 0xc0, 0x0f, 0xfe, 0x00, 0x00, 0xff, 0xf0,

    0x00, 0x1f, 0xfe, 0x00, 0x00, 0xff, 0xe0, 0x3f, 0xfc, 0x00, 0x01, 0xff, 0xe0, 0x00, 0x07, 0xff,

    0x00, 0x00, 0x7f, 0xf0, 0x1f, 0xf0, 0x00, 0x07, 0xff, 0x80, 0x00, 0x03, 0xff, 0xc0, 0x00, 0x1f,

    0xf0, 0x0f, 0xe0, 0x00, 0x0f, 0xff, 0x00, 0x00, 0x00, 0xff, 0xe0, 0x00, 0x0f, 0xe0, 0x03, 0xc0,

    0x00, 0x3f, 0xfc, 0x00, 0x00, 0x00, 0x7f, 0xf8, 0x00, 0x03, 0x80, 0x01, 0x00, 0x00, 0x7f, 0xf8,

    0x00, 0x00, 0x00, 0x1f, 0xfc, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0xff, 0xe0, 0x00, 0x00, 0x00,

    0x0f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x03, 0xff, 0x80,

    0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xe0, 0x00, 0x00, 0x00,

    0x00, 0x1f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xf8,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf0, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x0f, 0xfe, 0x00, 0x00, 0x00, 0x03, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,

    0xff, 0x80, 0x00, 0x00, 0x07, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xc0, 0x00,

    0x00, 0x1f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf0, 0x00, 0x00, 0x3f, 0xfc,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf8, 0x00, 0x00, 0xff, 0xf0, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x00, 0x1f, 0xfe, 0x00, 0x01, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x00, 0x07, 0xff, 0x00, 0x07, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff,

    0xc0, 0x0f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xe0, 0x3f, 0xfc,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xf0, 0x1f, 0xf0, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xf0, 0x0f, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x0f, 0xe0, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x03, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00

    };

    const unsigned char down [] PROGMEM = {

    // 'Downward, 105x64px

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0xe0,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x03, 0xf8, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x0f, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x07, 0xf0, 0x0f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x1f, 0xf0, 0x03, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xf0, 0x01,

    0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf0, 0x00, 0x7f, 0xf0, 0x00,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xc0, 0x00, 0x3f, 0xfc, 0x00, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x07, 0xff, 0x80, 0x00, 0x0f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x1f, 0xfe, 0x00, 0x00, 0x07, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x00,

    0x00, 0x01, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xff,

    0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x3f, 0xf8, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x07, 0xff, 0x80, 0x00, 0x00, 0x00, 0x1f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x0f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x00,

    0x00, 0x00, 0x00, 0x03, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00,

    0x00, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x01, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xf8,

    0x00, 0x00, 0x00, 0x03, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x40, 0x00, 0x1f, 0xfc, 0x00, 0x00, 0x00,

    0x0f, 0xff, 0x00, 0x00, 0x40, 0x00, 0xe0, 0x00, 0x0f, 0xff, 0x00, 0x00, 0x00, 0x1f, 0xfe, 0x00,

    0x01, 0xe0, 0x03, 0xf8, 0x00, 0x03, 0xff, 0x80, 0x00, 0x00, 0x7f, 0xf8, 0x00, 0x03, 0xf0, 0x0f,

    0xfc, 0x00, 0x01, 0xff, 0xe0, 0x00, 0x00, 0xff, 0xf0, 0x00, 0x07, 0xf0, 0x0f, 0xff, 0x00, 0x00,

    0x7f, 0xf0, 0x00, 0x03, 0xff, 0xc0, 0x00, 0x1f, 0xf0, 0x03, 0xff, 0x80, 0x00, 0x3f, 0xfc, 0x00,

    0x07, 0xff, 0x80, 0x00, 0x3f, 0xf0, 0x01, 0xff, 0xe0, 0x00, 0x0f, 0xfe, 0x00, 0x1f, 0xfe, 0x00,

    0x00, 0xff, 0xf0, 0x00, 0x7f, 0xf0, 0x00, 0x07, 0xff, 0x80, 0x3f, 0xfc, 0x00, 0x03, 0xff, 0xc0,

    0x00, 0x3f, 0xfc, 0x00, 0x01, 0xff, 0xc0, 0xff, 0xf0, 0x00, 0x07, 0xff, 0x80, 0x00, 0x0f, 0xfe,

    0x00, 0x00, 0xff, 0xf1, 0xff, 0xe0, 0x00, 0x1f, 0xfe, 0x00, 0x00, 0x07, 0xff, 0x80, 0x00, 0x3f,

    0xff, 0xff, 0x80, 0x00, 0x3f, 0xfc, 0x00, 0x00, 0x01, 0xff, 0xc0, 0x00, 0x1f, 0xff, 0xff, 0x00,

    0x00, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xf0, 0x00, 0x07, 0xff, 0xfc, 0x00, 0x01, 0xff, 0xe0,

    0x00, 0x00, 0x00, 0x3f, 0xf8, 0x00, 0x03, 0xff, 0xf8, 0x00, 0x07, 0xff, 0x80, 0x00, 0x00, 0x00,

    0x1f, 0xfe, 0x00, 0x00, 0xff, 0xe0, 0x00, 0x0f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0x00,

    0x00, 0x7f, 0xc0, 0x00, 0x3f, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xc0, 0x00, 0x1f, 0x00,

    0x00, 0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xe0, 0x00, 0x0e, 0x00, 0x01, 0xff, 0xe0,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xf8, 0x00, 0x00, 0x00, 0x03, 0xff, 0xc0, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x1f, 0xfc, 0x00, 0x00, 0x00, 0x0f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f,

    0xff, 0x00, 0x00, 0x00, 0x1f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0x80, 0x00,

    0x00, 0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xe0, 0x00, 0x00, 0xff, 0xf0,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xf0, 0x00, 0x03, 0xff, 0xc0, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x00, 0x07, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x00, 0x0f, 0xfe, 0x00, 0x1f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff,

    0x80, 0x3f, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xc0, 0xff, 0xf0,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xff, 0xe0, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x07, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xf8,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xe0, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00

    };

    const unsigned char uparrow [] PROGMEM = {

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x80, 0x00, 0x00, 0x00,

    0xff, 0xc0, 0x00, 0x00, 0x01, 0xff, 0xf0, 0x00, 0x00, 0x03, 0xff, 0xf8, 0x00, 0x00, 0x07, 0xff,

    0xfc, 0x00, 0x00, 0x1f, 0xff, 0xff, 0x00, 0x00, 0x3f, 0xff, 0xff, 0x80, 0x00, 0xff, 0xff, 0xff,

    0xc0, 0x01, 0xff, 0xff, 0xff, 0xf0, 0x03, 0xff, 0xff, 0xff, 0xf8, 0x03, 0xff, 0xff, 0xff, 0xf8,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00

    };

    const unsigned char downarrow [] PROGMEM = {

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xc0, 0x1f,

    0xff, 0xff, 0xff, 0xc0, 0x0f, 0xff, 0xff, 0xff, 0x80, 0x03, 0xff, 0xff, 0xff, 0x00, 0x01, 0xff,

    0xff, 0xfc, 0x00, 0x00, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x3f, 0xff, 0xe0, 0x00, 0x00, 0x1f, 0xff,

    0xc0, 0x00, 0x00, 0x0f, 0xff, 0x80, 0x00, 0x00, 0x03, 0xff, 0x00, 0x00, 0x00, 0x01, 0xfc, 0x00,

    0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00

    };

    const unsigned char dooropen [] PROGMEM = {

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xc0, 0x1f, 0xff, 0xff, 0xe0,

    0x3f, 0xff, 0xff, 0xe0, 0x3f, 0xff, 0xff, 0xf0, 0x38, 0x00, 0x00, 0xf0, 0x38, 0x00, 0x00, 0xf0,

    0x38, 0x00, 0x00, 0xf0, 0x38, 0x04, 0x80, 0xf0, 0x38, 0x1c, 0xc0, 0xf0, 0x38, 0x3c, 0xf0, 0xf0,

    0x38, 0x7c, 0xf8, 0xf0, 0x39, 0xfc, 0xfc, 0xf0, 0x3b, 0xfc, 0xfe, 0xf0, 0x3b, 0xfc, 0xfe, 0xf0,

    0x38, 0xfc, 0xfc, 0xf0, 0x38, 0x7c, 0xf8, 0xf0, 0x38, 0x3c, 0xf0, 0xf0, 0x38, 0x1c, 0xc0, 0xf0,

    0x38, 0x04, 0x80, 0xf0, 0x38, 0x00, 0x00, 0xf0, 0x38, 0x00, 0x00, 0xf0, 0x38, 0x00, 0x00, 0xf0,

    0x3c, 0x00, 0x00, 0xf0, 0x3f, 0xff, 0xff, 0xe0, 0x1f, 0xff, 0xff, 0xe0, 0x1f, 0xff, 0xff, 0xc0,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00

    };

    const unsigned char door [] PROGMEM = {

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x0f, 0xff, 0xff, 0xc0, 0x0f, 0xff, 0xff, 0xc0, 0x08, 0x00, 0x00, 0x40, 0x0a, 0x00, 0x03, 0x40,

    0x0b, 0x80, 0x07, 0x40, 0x0b, 0xc0, 0x0f, 0x40, 0x0b, 0xe0, 0x1f, 0x40, 0x0b, 0xf0, 0x3f, 0x40,

    0x0b, 0xf8, 0x7f, 0x40, 0x0b, 0xfc, 0xff, 0x40, 0x0b, 0xff, 0xff, 0x40, 0x0b, 0xff, 0xff, 0x40,

    0x0b, 0xfe, 0xff, 0x40, 0x0b, 0xf8, 0x7f, 0x40, 0x0b, 0xf0, 0x3f, 0x40, 0x0b, 0xe0, 0x1f, 0x40,

    0x0b, 0xc0, 0x0f, 0x40, 0x0b, 0x80, 0x07, 0x40, 0x0b, 0x00, 0x03, 0x40, 0x08, 0x00, 0x01, 0x40,

    0x0f, 0xff, 0xff, 0xc0, 0x0f, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00

    };

    void setup() {

    SerialNumber.Start(9600);

    if (!APDS.begin()) {

    Serial.println("Error initializing APDS9960 sensor!");

    }

    Serial.println("Detect gesture...");

    display.begin(SH1106_SWITCHCAPVCC, 0x3C);

    display.setTextSize(2);

    display.setTextColor(white);

    display.clearDisplay();

    display.show();

    Home1();

    }

    void loop(){

    display.clearDisplay();

    if (APDS.gestureAvailable()) {

    int gesture = APDS.readGesture();

    toggle(gesture) {

    Case GESTURE_UP:

Serial.println("Upward gesture detected");

display.clearDisplay();

Number of floors++;

Home1();

rest;

    case GESTURE_DOWN:

Serial.println("Downward gesture detected");

display.clearDisplay();

Floor Number——;

Home1();

rest;

    Case GESTURE_LEFT:

Serial.println("Left gesture detected");

display.clearDisplay();

start();

rest;

    Case GESTURE_RIGHT:

Serial.println("Correct gesture detected");

display.clearDisplay();

Home1();

rest;

default:

rest;

    }

    }

    }

    void home1()

    {

    display.setCursor(101,23);

    display.println(floornum);

    display.drawBitmap(23, 0, uparrow, 40, 18, WHITE);

    display.drawBitmap(26, 46, downarrow, 40, 18, WHITE);

    display.drawBitmap(0, 15, dooropen, 29, 30, WHITE);

    display.drawBitmap(60, 15, closedoor, 29, 30, WHITE);

    display.show();

    }

    void begin()

    {

    while (floor number > current floor) {

    Serial.println("Up");

    Current Floor++;

    display.drawBitmap(0, 0, up, 100, 64, WHITE);

    display.setCursor(101,23);

    display.println(currentfloor);

    display.show();

    display.clearDisplay();

    delay(2000);

    }

    while (floor number < current floor) {

    Serial.println("Go down");

    Current floor——;

    display.drawBitmap(0, 0, down, 100, 64, WHITE);

    display.setCursor(101,23);

    display.println(currentfloor);

    display.show();

    display.clearDisplay();

    delay(2000);

    }

    if (floorNumber == currentFloor) {

Serial.println("arrived");

display.clearDisplay();

Home1();

Serial.print(currentfloor);

    }

    }

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号