物联网毕设 基于单片机的手势识别系统


0 前言

🔥 这两年开始毕业设计和毕业答辩的要求和难度不断提升,传统的毕设题目缺少创新和亮点,往往达不到毕业答辩的要求,这两年不断有学弟学妹告诉学长自己做的项目系统达不到老师的要求。

为了大家能够顺利以及最少的精力通过毕设,学长分享优质毕业设计项目,今天要分享的是

🚩 **基于单片机的手势识别系统 **

🥇学长这里给一个题目综合评分(每项满分5分)

  • 难度系数:4分
  • 工作量:4分
  • 创新点:3分

🧿 毕设项目分享:见文末!


1 简介

非接触式手势是人机交互世界的新前沿科技。通过在传感器上滑动您的手掌,您可以控制计算机、微控制器、机器人等。
本项目中,我们将简单介绍APDS9960传感器,然后将其与Arduino UNO开发板连接。首先,我们将介绍分线板模块上的每个引脚及其功能,通过I2C引脚连接传感器。我们将测量手势方向,如左、右、上、下、近和远。然后,我们将使用该传感器作为RGB颜色检测器和接近感应测试。

2 主要器件

  • Arduino UNO开发板
  • 0.96寸I2C OLED显示屏
  • APDS9960手势、光线、接近和颜色传感器
  • 连接跳线
  • 面包板

3 实现效果

在这里插入图片描述
在这里插入图片描述

4 硬件设计

APDS9960接近、光线、RGB颜色和手势传感器

APDS-9960是一款多功能传感器,可以检测手势、环境光、RGB颜色和光线值。

在这里插入图片描述
该传感器由四个光电二极管组成。这些光电二极管检测由板载LED传输的反射红外能量。因此,无论何时执行任何手势,此IR能量都会被阻挡并反射回传感器,传感器检测速度和方向信息并将其转换为数字信息。APDS-9960的检测范围在10到20厘米之间。

该传感器采用I2C通信协议。工作电流大约为1µA,由3.3V供电,因此不要将其与5V引脚连接。这里的INT管脚是中断管脚,用来驱动I2C通信。

在这里插入图片描述
手势引擎的架构具有自动激活(基于Proximity引擎结果)、环境光减法、串扰消除、双8位数据转换器、省电转换延迟、32位数据集FIFO和中断驱动I2C通信。通过可调节的IR LED时序将功耗和噪声降至最低。

APDS9960 传感器有6个引脚。以下是各个引脚的功能。

在这里插入图片描述

将APDS9960传感器与Arduino连接

本文使用Arduino UNO开发板来连接APDS9960传感器。使用3.3V为传感器供电。

在这里插入图片描述
将传感器的SDA引脚连接到Arduino开发板的A4引脚,将SCL连接到A5引脚,将INT连接到D2引脚。传感器分线板上的VL处于未连接状态。

在这里插入图片描述

APDS9960手势传感器与Arduino和OLED显示屏的连接

现在让我们在电路中添加一个I2C OLED显示屏,以便可以在OLED显示屏上查看手势数据。所以如下图所示进行连接。
在这里插入图片描述

5 软件说明

在Arduino IDE上安装APDS9960库

APDS9960传感器的Arduino库由Sparkfun创建。该库使APDS-9960易于使用。

要安装库,请转到Arduino IDE中的库管理器并安装以下Sparkfun库,如下图所示。

在这里插入图片描述

手势感应示例

以下是使用APDS9960传感器感应手势的代码:

#include <Wire.h>
#include <SparkFun_APDS9960.h>
 
#define APDS9960_INT    2 // Needs to be an interrupt pin
 
// Global Variables
SparkFun_APDS9960 apds = SparkFun_APDS9960();
int isr_flag = 0;
 
void setup() {
 
  // Initialize Serial port
  Serial.begin(9600);
  Serial.println();
  Serial.println(F("--------------------------------"));
  Serial.println(F("APDS-9960 - GestureTest"));
  Serial.println(F("--------------------------------"));
 
  // Initialize interrupt service routine
  attachInterrupt(0, interruptRoutine, FALLING);
 
  // Initialize APDS-9960 (configure I2C and initial values)
  if ( apds.init() ) {
    Serial.println(F("APDS-9960 initialization complete"));
  } else {
    Serial.println(F("Something went wrong during APDS-9960 init!"));
  }
 
  // Start running the APDS-9960 gesture sensor engine
  if ( apds.enableGestureSensor(true) ) {
    Serial.println(F("Gesture sensor is now running"));
  } else {
    Serial.println(F("Something went wrong during gesture sensor init!"));
  }
}
 
void loop() {
  if( isr_flag == 1 ) {
    detachInterrupt(0);
    handleGesture();
    isr_flag = 0;
    attachInterrupt(0, interruptRoutine, FALLING);
  }
}
 
void interruptRoutine() {
  isr_flag = 1;
}
 
void handleGesture() {
    if ( apds.isGestureAvailable() ) {
    switch ( apds.readGesture() ) {
      case DIR_UP:
        Serial.println("UP");
        break;
      case DIR_DOWN:
        Serial.println("DOWN");
        break;
      case DIR_LEFT:
        Serial.println("LEFT");
        break;
      case DIR_RIGHT:
        Serial.println("RIGHT");
        break;
      case DIR_NEAR:
        Serial.println("NEAR");
        break;
      case DIR_FAR:
        Serial.println("FAR");
        break;
      default:
        Serial.println("NONE");
    }
  }
}

上传代码后,向左、向右、向前、向后滑动您的手掌。 每当检测到中断时,串口监视器将显示手势数据。
在这里插入图片描述

感应颜色示例

以下是使用APDS9960传感器检测不同颜色的代码:

#include <Wire.h>
#include <SparkFun_APDS9960.h>
 
// Global Variables
SparkFun_APDS9960 apds = SparkFun_APDS9960();
uint16_t ambient_light = 0;
uint16_t red_light = 0;
uint16_t green_light = 0;
uint16_t blue_light = 0;
 
void setup() {
  
  // Initialize Serial port
  Serial.begin(9600);
  Serial.println();
  Serial.println(F("--------------------------------"));
  Serial.println(F("APDS-9960 - ColorSensor"));
  Serial.println(F("--------------------------------"));
  
  // Initialize APDS-9960 (configure I2C and initial values)
  if ( apds.init() ) {
    Serial.println(F("APDS-9960 initialization complete"));
  } else {
    Serial.println(F("Something went wrong during APDS-9960 init!"));
  }
  
  // Start running the APDS-9960 light sensor (no interrupts)
  if ( apds.enableLightSensor(false) ) {
    Serial.println(F("Light sensor is now running"));
  } else {
    Serial.println(F("Something went wrong during light sensor init!"));
  }
  
  // Wait for initialization and calibration to finish
  delay(500);
}
 
void loop() {
  
  // Read the light levels (ambient, red, green, blue)
  if (  !apds.readAmbientLight(ambient_light) ||
        !apds.readRedLight(red_light) ||
        !apds.readGreenLight(green_light) ||
        !apds.readBlueLight(blue_light) ) {
    Serial.println("Error reading light values");
  } else {
    Serial.print("Ambient: ");
    Serial.print(ambient_light);
    Serial.print(" Red: ");
    Serial.print(red_light);
    Serial.print(" Green: ");
    Serial.print(green_light);
    Serial.print(" Blue: ");
    Serial.println(blue_light);
  }
  
  // Wait 1 second before next reading
  delay(1000);
}

现在为了查看颜色频率的变化,将不同颜色的物体放在传感器前面。 串口监视器将显示红色、绿色、蓝色的值以及环境颜色值。

在这里插入图片描述

显示屏配置

为OLED显示屏添加这两个库。

  • Adafruit GFX库
  • SSD1306库

以下是APDS9960手势传感器与Arduino和OLED显示屏的连接的完整代码:

#include <Wire.h>
#include <SparkFun_APDS9960.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
 
#define APDS9960_INT    2 // Needs to be an interrupt pin
 
 
#define SCREEN_WIDTH 128    // OLED display width, in pixels
#define SCREEN_HEIGHT 64    // OLED display height, in pixels
#define OLED_RESET 4        // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
 
#define LOGO_HEIGHT   64
#define LOGO_WIDTH    64
static const unsigned char PROGMEM myleft[] =
{ 
  0x45, 0x45, 0x45, 0xff,   /*Color of index 0*/
  0xe9, 0xea, 0xe9, 0xff,   /*Color of index 1*/
 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe1, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd0, 0x7f, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x7f, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x3f, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x3f, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x1f, 
  0xff, 0xff, 0xff, 0xe7, 0xff, 0xff, 0xf8, 0x1f, 
  0xff, 0xff, 0xff, 0xc7, 0xff, 0xff, 0xfc, 0x0f, 
  0xff, 0xff, 0xff, 0x87, 0xff, 0xff, 0xfc, 0x0f, 
  0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xfe, 0x0f, 
  0xff, 0xff, 0xfe, 0x07, 0xff, 0xff, 0xfe, 0x07, 
  0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0xfe, 0x07, 
  0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xfe, 0x07, 
  0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0xfe, 0x07, 
  0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0xff, 0x03, 
  0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0xff, 0x03, 
  0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x03, 
  0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x03, 
  0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0xff, 0x03, 
  0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0xff, 0x03, 
  0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0xfe, 0x03, 
  0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xfe, 0x03, 
  0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0xfe, 0x07, 
  0xff, 0xff, 0xfc, 0x07, 0xff, 0xff, 0xfe, 0x07, 
  0xff, 0xff, 0xfe, 0x07, 0xff, 0xff, 0xfc, 0x07, 
  0xff, 0xff, 0xff, 0x87, 0xff, 0xff, 0xfc, 0x07, 
  0xff, 0xff, 0xff, 0xc7, 0xff, 0xff, 0xfc, 0x07, 
  0xff, 0xff, 0xff, 0xe7, 0xff, 0xff, 0xf8, 0x0f, 
  0xff, 0xff, 0xff, 0xf7, 0xff, 0xff, 0xf8, 0x0f, 
  0xff, 0xef, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x1f, 
  0xff, 0xef, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x1f, 
  0xff, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x1f, 
  0xff, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x3f, 
  0xff, 0xf9, 0xff, 0xff, 0xff, 0xff, 0x80, 0x7f, 
  0xff, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x00, 0x7f, 
  0xff, 0x7c, 0x7f, 0xff, 0xff, 0xfe, 0x00, 0xff, 
  0xff, 0xbe, 0x1f, 0xff, 0xff, 0xf8, 0x01, 0xff, 
  0xff, 0xdf, 0x0f, 0xff, 0xff, 0xf0, 0x01, 0xff, 
  0xff, 0xe0, 0x03, 0xff, 0xff, 0xc0, 0x03, 0xff, 
  0xff, 0xf0, 0x00, 0x7f, 0xfe, 0x00, 0x07, 0xff, 
  0xff, 0xf8, 0x00, 0x03, 0xc0, 0x00, 0x0f, 0xff, 
  0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 
  0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 
  0xff, 0xff, 0x80, 0x00, 0x00, 0x01, 0xff, 0xff, 
  0xff, 0xff, 0xc0, 0x00, 0x00, 0x03, 0xff, 0xff, 
  0xff, 0xff, 0xf8, 0x00, 0x00, 0x0f, 0xff, 0xff, 
  0xff, 0xff, 0xfe, 0x00, 0x00, 0x7f, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
};
 
static const unsigned char PROGMEM myright[] =
{ 0x33, 0x34, 0x33, 0xff,   /*Color of index 0*/
  0xec, 0xed, 0xec, 0xff,   /*Color of index 1*/
 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xff, 0xff, 
  0xff, 0xff, 0xf8, 0x00, 0x00, 0x0f, 0xff, 0xff, 
  0xff, 0xff, 0xe0, 0x00, 0x00, 0x03, 0xff, 0xff, 
  0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 
  0xff, 0xfe, 0x00, 0x0f, 0xf0, 0x00, 0x7f, 0xff, 
  0xff, 0xfc, 0x00, 0xff, 0xff, 0x00, 0x1f, 0xff, 
  0xff, 0xf8, 0x03, 0xff, 0xff, 0xc6, 0x0f, 0xff, 
  0xff, 0xf0, 0x0f, 0xff, 0xff, 0xf0, 0x07, 0xff, 
  0xff, 0xe0, 0x1f, 0xff, 0xff, 0xfc, 0x03, 0xff, 
  0xff, 0xc0, 0x3f, 0xff, 0xff, 0xfe, 0x01, 0xff, 
  0xff, 0x80, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 
  0xff, 0x01, 0xff, 0xff, 0xff, 0xff, 0x80, 0x7f, 
  0xff, 0x03, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x7f, 
  0xfe, 0x03, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x3f, 
  0xfc, 0x07, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x3f, 
  0xfc, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x1f, 
  0xf8, 0x0f, 0xff, 0xff, 0xef, 0xff, 0xf8, 0x1f, 
  0xf8, 0x1f, 0xff, 0xff, 0xe7, 0xff, 0xf8, 0x0f, 
  0xf0, 0x3f, 0xff, 0xff, 0xe3, 0xff, 0xfc, 0x0f, 
  0xf0, 0x3f, 0xff, 0xff, 0xe1, 0xff, 0xfc, 0x07, 
  0xf0, 0x3f, 0xff, 0xff, 0xe0, 0xff, 0xfc, 0x07, 
  0xf0, 0x7f, 0xff, 0xff, 0xe0, 0x3f, 0xfe, 0x07, 
  0xe0, 0x7f, 0x00, 0x00, 0x00, 0x1f, 0xfe, 0x07, 
  0xe0, 0x7f, 0x00, 0x00, 0x00, 0x0f, 0xfe, 0x03, 
  0xe0, 0x7f, 0x00, 0x00, 0x00, 0x07, 0xfe, 0x03, 
  0xe0, 0xff, 0x00, 0x00, 0x00, 0x03, 0xfe, 0x03, 
  0xe0, 0xff, 0x00, 0x00, 0x00, 0x01, 0xff, 0x03, 
  0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x03, 
  0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x03, 
  0xe0, 0xff, 0x00, 0x00, 0x00, 0x01, 0xff, 0x03, 
  0xe0, 0xff, 0x00, 0x00, 0x00, 0x03, 0xfe, 0x03, 
  0xe0, 0x7f, 0x00, 0x00, 0x00, 0x07, 0xfe, 0x03, 
  0xe0, 0x7f, 0x00, 0x00, 0x00, 0x0f, 0xfe, 0x03, 
  0xe0, 0x7f, 0x00, 0x00, 0x00, 0x1f, 0xfe, 0x03, 
  0xe0, 0x7f, 0xff, 0xff, 0xe0, 0x7f, 0xfe, 0x03, 
  0xe0, 0x3f, 0xff, 0xff, 0xe0, 0xff, 0xfc, 0x07, 
  0xe0, 0x3f, 0xff, 0xff, 0xe1, 0xff, 0xfc, 0x07, 
  0xf0, 0x1f, 0xff, 0xff, 0xe3, 0xff, 0xf8, 0x07, 
  0xf0, 0x1f, 0xff, 0xff, 0xe7, 0xff, 0xf8, 0x07, 
  0xf0, 0x0f, 0xff, 0xff, 0xef, 0xff, 0xf0, 0x0f, 
  0xf8, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x0f, 
  0xf8, 0x07, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x1f, 
  0xfc, 0x83, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x1f, 
  0xfc, 0x41, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x3f, 
  0xfe, 0x80, 0xff, 0xff, 0xff, 0xff, 0x80, 0x3f, 
  0xfe, 0x00, 0x7f, 0xff, 0xff, 0xff, 0x00, 0x7f, 
  0xff, 0x00, 0x3f, 0xff, 0xff, 0xfc, 0x00, 0xff, 
  0xff, 0x80, 0x1f, 0xff, 0xff, 0xf8, 0x00, 0xff, 
  0xff, 0xc0, 0x07, 0xff, 0xff, 0xe0, 0x01, 0xff, 
  0xff, 0xe0, 0x01, 0xff, 0xff, 0x80, 0x03, 0xff, 
  0xff, 0xf0, 0x00, 0x3f, 0xfc, 0x00, 0x07, 0xff, 
  0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 
  0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 
  0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 
  0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 
  0xff, 0xff, 0xe0, 0x00, 0x00, 0x03, 0xff, 0xff, 
  0xff, 0xff, 0xf8, 0x00, 0x00, 0x0f, 0xff, 0xff, 
  0xff, 0xff, 0xfe, 0x00, 0x00, 0x3f, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
};
 
 
static const unsigned char PROGMEM myup[] =
{ 0x2d, 0x2d, 0x2d, 0xff,   /*Color of index 0*/
  0xf5, 0xf6, 0xf5, 0xff,   /*Color of index 1*/
 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xf0, 0x3f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xfe, 0x00, 0x01, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xf0, 0x00, 0x00, 0x3f, 0xff, 0xff, 
  0xff, 0xff, 0xc0, 0x00, 0x00, 0x0f, 0xff, 0xff, 
  0xff, 0xff, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 
  0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 
  0xff, 0xf8, 0x00, 0x7f, 0xf8, 0x00, 0x7f, 0xff, 
  0xff, 0xf0, 0x03, 0xff, 0xff, 0x00, 0x3f, 0xff, 
  0xff, 0xc0, 0x0f, 0xff, 0xff, 0xc0, 0x1f, 0xff, 
  0xff, 0x80, 0x3f, 0xff, 0xff, 0xf0, 0x07, 0xff, 
  0xff, 0x80, 0x7f, 0xff, 0xff, 0xf8, 0x03, 0xff, 
  0xff, 0x00, 0xff, 0xff, 0xff, 0xfc, 0x03, 0xff, 
  0xfe, 0x01, 0xff, 0xff, 0xff, 0xfe, 0x01, 0xff, 
  0xfc, 0x03, 0xff, 0xfc, 0xff, 0xff, 0x00, 0xff, 
  0xfc, 0x07, 0xff, 0xf8, 0x7f, 0xff, 0x80, 0xff, 
  0xf8, 0x0f, 0xff, 0xf0, 0x3f, 0xff, 0xc0, 0x7f, 
  0xf0, 0x1f, 0xff, 0xf0, 0x3f, 0xff, 0xe0, 0x3f, 
  0xf0, 0x1f, 0xff, 0xe0, 0x1f, 0xff, 0xe0, 0x3f, 
  0xe0, 0x3f, 0xff, 0xc0, 0x0f, 0xff, 0xf0, 0x1f, 
  0xe0, 0x3f, 0xff, 0x80, 0x07, 0xff, 0xf0, 0x1f, 
  0xe0, 0x7f, 0xff, 0x00, 0x03, 0xff, 0xf8, 0x1f, 
  0xc0, 0x7f, 0xfe, 0x00, 0x01, 0xff, 0xf8, 0x0f, 
  0xc0, 0x7f, 0xfc, 0x00, 0x00, 0xff, 0xf8, 0x0f, 
  0xc0, 0xff, 0xf8, 0x00, 0x00, 0x7f, 0xfc, 0x0f, 
  0xc0, 0xff, 0xf0, 0x00, 0x00, 0x3f, 0xfc, 0x0f, 
  0x80, 0xff, 0xe0, 0x00, 0x00, 0x1f, 0xfc, 0x07, 
  0x80, 0xff, 0xff, 0x80, 0x07, 0xff, 0xfc, 0x07, 
  0x80, 0xff, 0xff, 0x80, 0x07, 0xff, 0xfc, 0x07, 
  0x80, 0xff, 0xff, 0x80, 0x07, 0xff, 0xfc, 0x07, 
  0x80, 0xff, 0xff, 0x80, 0x07, 0xff, 0xfc, 0x07, 
  0x80, 0xff, 0xff, 0x80, 0x07, 0xff, 0xfc, 0x07, 
  0x80, 0xff, 0xff, 0x80, 0x07, 0xff, 0xfc, 0x07, 
  0x80, 0xff, 0xff, 0x80, 0x07, 0xff, 0xfc, 0x07, 
  0x80, 0xff, 0xff, 0x80, 0x07, 0xff, 0xfc, 0x07, 
  0x80, 0xff, 0xff, 0x80, 0x07, 0xff, 0xfc, 0x07, 
  0xc0, 0xff, 0xff, 0x80, 0x07, 0xff, 0xfc, 0x07, 
  0xc0, 0x7f, 0xff, 0x80, 0x07, 0xff, 0xf8, 0x0f, 
  0xc0, 0x7f, 0xff, 0x80, 0x07, 0xff, 0xf8, 0x0f, 
  0xc0, 0x7f, 0xff, 0x80, 0x07, 0xff, 0xf8, 0x0f, 
  0xe0, 0x3f, 0xff, 0x80, 0x07, 0xff, 0xf0, 0x1f, 
  0xe0, 0x3f, 0xff, 0x80, 0x07, 0xff, 0xf0, 0x1f, 
  0xe0, 0x1f, 0xff, 0x80, 0x07, 0xff, 0xe0, 0x1f, 
  0xf0, 0x0f, 0xff, 0x80, 0x07, 0xff, 0xc0, 0x3f, 
  0xf0, 0x0f, 0xff, 0x80, 0x07, 0xff, 0xc0, 0x3f, 
  0xf8, 0x07, 0xff, 0x80, 0x07, 0xff, 0x80, 0x7f, 
  0xf8, 0x03, 0xff, 0x80, 0x07, 0xff, 0x00, 0x7f, 
  0xfc, 0x01, 0xff, 0xff, 0xff, 0xfe, 0x00, 0xff, 
  0xfe, 0x00, 0xff, 0xff, 0xff, 0xfc, 0x01, 0xff, 
  0xfe, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x01, 0xff, 
  0xff, 0x00, 0x1f, 0xff, 0xff, 0xe0, 0x03, 0xff, 
  0xff, 0x80, 0x07, 0xff, 0xff, 0x80, 0x07, 0xff, 
  0xff, 0xc0, 0x00, 0xff, 0xfc, 0x00, 0x0f, 0xff, 
  0xff, 0xe0, 0x00, 0x0f, 0xc0, 0x00, 0x1f, 0xff, 
  0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 
  0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 
  0xff, 0xfe, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 
  0xff, 0xff, 0x80, 0x00, 0x00, 0x07, 0xff, 0xff, 
  0xff, 0xff, 0xe0, 0x00, 0x00, 0x1f, 0xff, 0xff, 
  0xff, 0xff, 0xf8, 0x00, 0x00, 0x7f, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0x00, 0x03, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
};
 
 
static const unsigned char PROGMEM mydown[] =
{ 0x3f, 0x3f, 0x3f, 0xff,   /*Color of index 0*/
  0xea, 0xeb, 0xea, 0xff,   /*Color of index 1*/
 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x7f, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xb8, 0x1f, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xe4, 0x0f, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xfa, 0x07, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x03, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x01, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x7f, 
  0xff, 0xff, 0xff, 0xe0, 0x01, 0xff, 0xc0, 0x7f, 
  0xff, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xe0, 0x3f, 
  0xff, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xf0, 0x1f, 
  0xff, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xf8, 0x1f, 
  0xff, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xf8, 0x0f, 
  0xff, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xfc, 0x0f, 
  0xff, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xfc, 0x0f, 
  0xff, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xfe, 0x07, 
  0xff, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xfe, 0x07, 
  0xff, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xfe, 0x03, 
  0xff, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xff, 0x03, 
  0xff, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xff, 0x03, 
  0xff, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xff, 0x03, 
  0xff, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xff, 0x03, 
  0xff, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xff, 0x03, 
  0xff, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xff, 0x03, 
  0xff, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xff, 0x01, 
  0xff, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xff, 0x01, 
  0xff, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xff, 0x01, 
  0xff, 0xff, 0xf8, 0x00, 0x00, 0x0f, 0xff, 0x03, 
  0xff, 0xff, 0xfc, 0x00, 0x00, 0x0f, 0xff, 0x03, 
  0xff, 0xff, 0xfc, 0x00, 0x00, 0x1f, 0xff, 0x03, 
  0xff, 0xff, 0xfe, 0x00, 0x00, 0x3f, 0xfe, 0x03, 
  0xff, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xfe, 0x03, 
  0xf7, 0xff, 0xff, 0x80, 0x00, 0xff, 0xfe, 0x03, 
  0xff, 0xdf, 0xff, 0xc0, 0x01, 0xff, 0xfc, 0x07, 
  0xff, 0xdf, 0xff, 0xe0, 0x03, 0xff, 0xfc, 0x07, 
  0xfb, 0xef, 0xff, 0xf0, 0x07, 0xff, 0xf8, 0x07, 
  0xf9, 0xef, 0xff, 0xf8, 0x07, 0xff, 0xf8, 0x0f, 
  0xfd, 0xe7, 0xff, 0xfc, 0x0f, 0xff, 0xf0, 0x0f, 
  0xfc, 0x13, 0xff, 0xfc, 0x1f, 0xff, 0xe0, 0x1f, 
  0xfe, 0x01, 0xff, 0xfe, 0x3f, 0xff, 0xc0, 0x1f, 
  0xfe, 0x00, 0xff, 0xff, 0xff, 0xff, 0x80, 0x3f, 
  0xff, 0x00, 0x7f, 0xff, 0xff, 0xff, 0x00, 0x3f, 
  0xff, 0x80, 0x3f, 0xff, 0xff, 0xfe, 0x00, 0x7f, 
  0xff, 0x80, 0x1f, 0xff, 0xff, 0xfc, 0x00, 0xff, 
  0xff, 0xc0, 0x07, 0xff, 0xff, 0xf0, 0x01, 0xff, 
  0xff, 0xe0, 0x01, 0xff, 0xff, 0xc0, 0x01, 0xff, 
  0xff, 0xf0, 0x00, 0x7f, 0xff, 0x00, 0x03, 0xff, 
  0xff, 0xf8, 0x00, 0x03, 0xe0, 0x00, 0x07, 0xff, 
  0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 
  0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 
  0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x7f, 0xff, 
  0xff, 0xff, 0xe0, 0x00, 0x00, 0x01, 0xff, 0xff, 
  0xff, 0xff, 0xf8, 0x00, 0x00, 0x07, 0xff, 0xff, 
  0xff, 0xff, 0xfe, 0x00, 0x00, 0x3f, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe0, 0x03, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
};
 
static const unsigned char PROGMEM mynear[] =
{ 0x59, 0x59, 0x59, 0xff,   /*Color of index 0*/
  0xf8, 0xf9, 0xf8, 0xff,   /*Color of index 1*/
 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe7, 0xef, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe3, 0xcf, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe1, 0x8f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe0, 0x07, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0x00, 0x01, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0x80, 0x03, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xc0, 0x07, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xf0, 0x0f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xf0, 0x1f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xf8, 0x3f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe0, 0x03, 0xff, 0xff, 0xff, 
  0xff, 0xf7, 0xff, 0x80, 0x01, 0xff, 0xef, 0xff, 
  0xff, 0xf3, 0xff, 0x00, 0x00, 0xff, 0xcf, 0xff, 
  0xff, 0xf1, 0xfe, 0x00, 0x00, 0x7f, 0x8f, 0xff, 
  0xff, 0xf0, 0xfe, 0x00, 0x00, 0x3f, 0x0f, 0xff, 
  0xc0, 0x00, 0x7c, 0x00, 0x00, 0x3e, 0x00, 0x03, 
  0xc0, 0x00, 0x3c, 0x00, 0x00, 0x1c, 0x00, 0x03, 
  0xe0, 0x00, 0x18, 0x00, 0x00, 0x18, 0x00, 0x0f, 
  0xf0, 0x00, 0x08, 0x00, 0x00, 0x10, 0x00, 0x1f, 
  0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 
  0xf8, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x1f, 
  0xf0, 0x00, 0x18, 0x00, 0x00, 0x10, 0x00, 0x0f, 
  0xe0, 0x00, 0x38, 0x00, 0x00, 0x18, 0x00, 0x07, 
  0xc0, 0x00, 0x7c, 0x00, 0x00, 0x1c, 0x00, 0x03, 
  0xff, 0xf0, 0xfc, 0x00, 0x00, 0x3e, 0x0f, 0xff, 
  0xff, 0xf1, 0xfc, 0x00, 0x00, 0x3f, 0x0f, 0xff, 
  0xff, 0xf3, 0xfe, 0x00, 0x00, 0x7f, 0x8f, 0xff, 
  0xff, 0xf7, 0xff, 0x00, 0x00, 0xff, 0xcf, 0xff, 
  0xff, 0xff, 0xff, 0x80, 0x01, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xc0, 0x03, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xf0, 0x0f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xf0, 0x0f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe0, 0x07, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xc0, 0x03, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0x80, 0x01, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe0, 0x07, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe1, 0x8f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe3, 0xcf, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe7, 0xef, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
};
 
 
static const unsigned char PROGMEM myfar[] =
{ 0x63, 0x64, 0x63, 0xff,   /*Color of index 0*/
  0xf8, 0xfa, 0xf8, 0xff,   /*Color of index 1*/
 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xfc, 0x7f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xf8, 0x3f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xf0, 0x1f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xc0, 0x07, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0x80, 0x03, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0x00, 0x01, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xfe, 0x00, 0x00, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe1, 0x0f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe3, 0x8f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe7, 0xcf, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xef, 0xef, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xf0, 0x0f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xc0, 0x03, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0x80, 0x01, 0xff, 0xff, 0xff, 
  0xff, 0xbf, 0xff, 0x00, 0x00, 0xff, 0xfd, 0xff, 
  0xff, 0x3f, 0xfe, 0x00, 0x00, 0x7f, 0xfc, 0xff, 
  0xfe, 0x3f, 0xfc, 0x00, 0x00, 0x3f, 0xfc, 0x7f, 
  0xfc, 0x3f, 0xfc, 0x00, 0x00, 0x3f, 0xfc, 0x3f, 
  0xf8, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x1f, 
  0xf0, 0x00, 0x08, 0x00, 0x00, 0x10, 0x00, 0x0f, 
  0xe0, 0x00, 0x18, 0x00, 0x00, 0x18, 0x00, 0x07, 
  0xc0, 0x00, 0x38, 0x00, 0x00, 0x1c, 0x00, 0x03, 
  0x80, 0x00, 0x78, 0x00, 0x00, 0x1e, 0x00, 0x01, 
  0xc0, 0x00, 0x38, 0x00, 0x00, 0x1c, 0x00, 0x03, 
  0xe0, 0x00, 0x18, 0x00, 0x00, 0x18, 0x00, 0x07, 
  0xf0, 0x00, 0x08, 0x00, 0x00, 0x10, 0x00, 0x0f, 
  0xf8, 0x00, 0x0c, 0x00, 0x00, 0x30, 0x00, 0x1f, 
  0xfc, 0x3f, 0xfc, 0x00, 0x00, 0x3f, 0xfc, 0x3f, 
  0xfe, 0x3f, 0xfe, 0x00, 0x00, 0x7f, 0xfc, 0x7f, 
  0xff, 0x3f, 0xff, 0x00, 0x00, 0x7f, 0xfc, 0xff, 
  0xff, 0xbf, 0xff, 0x00, 0x00, 0xff, 0xfd, 0xff, 
  0xff, 0xff, 0xff, 0xc0, 0x03, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xf7, 0xe7, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xf3, 0xc7, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xf1, 0x87, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe0, 0x07, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0x80, 0x01, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xc0, 0x03, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xe0, 0x07, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xf0, 0x0f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xff, 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
};
 
 
 
 
 
// Global Variables
SparkFun_APDS9960 apds = SparkFun_APDS9960();
int isr_flag = 0;
 
void setup() {
 
  // Initialize Serial port
  Serial.begin(9600);
  Serial.println();
  Serial.println(F("--------------------------------"));
  Serial.println(F("APDS-9960 - GestureTest"));
  Serial.println(F("--------------------------------"));
 
    display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //initialize with the I2C addr 0x3C (128x64)
    
 
 
  // Initialize interrupt service routine
  attachInterrupt(0, interruptRoutine, FALLING);
 
  // Initialize APDS-9960 (configure I2C and initial values)
  if ( apds.init() ) {
    Serial.println(F("APDS-9960 initialization complete"));
    display.clearDisplay();
    display.setCursor(0,0);  
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.println("ADPS Initialization");
    display.println("");
    display.setTextSize(2);
    display.println("Success! ");
    display.display();
  } else {
    Serial.println(F("Something went wrong during APDS-9960 init!"));
    display.clearDisplay();
    display.setCursor(0,0);  
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.println("ADPS Initialization");
    display.println("");
    display.setTextSize(2);
    display.println("Failed! ");
    display.display();
  }
 
  // Start running the APDS-9960 gesture sensor engine
  if ( apds.enableGestureSensor(true) ) {
    Serial.println(F("Gesture sensor is now running"));
    display.clearDisplay();
    display.setCursor(0,0);  
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.println("ADPS Initialization");
    display.println("");
    display.setTextSize(2);
    display.println("Success! ");
    display.display();
  } else {
    Serial.println(F("Something went wrong during gesture sensor init!"));
    display.clearDisplay();
    display.setCursor(0,0);  
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.println("ADPS Initialization");
    display.println("");
    display.setTextSize(2);
    display.println("Failed! ");
    display.display();
  }
}
 
void loop() {
  if( isr_flag == 1 ) {
    detachInterrupt(0);
    handleGesture();
    isr_flag = 0;
    attachInterrupt(0, interruptRoutine, FALLING);
  }
}
 
void interruptRoutine() {
  isr_flag = 1;
}
 
void handleGesture() {
    if ( apds.isGestureAvailable() ) {
    switch ( apds.readGesture() ) {
      case DIR_UP:
        Serial.println("UP");
        display.clearDisplay();
        display.drawBitmap(31, 0, myup, LOGO_WIDTH, LOGO_HEIGHT, 1);
        display.display();
        break;
      case DIR_DOWN:
        Serial.println("DOWN");
        display.clearDisplay();
        display.drawBitmap(31, 0, mydown, LOGO_WIDTH, LOGO_HEIGHT, 1);
        display.display();
        break;
      case DIR_LEFT:
        Serial.println("LEFT");
        display.clearDisplay();
        display.drawBitmap(31, 0, myleft, LOGO_WIDTH, LOGO_HEIGHT, 1);
        display.display();
        break;
      case DIR_RIGHT:
        Serial.println("RIGHT");
        display.clearDisplay();
        display.drawBitmap(31, 0, myright, LOGO_WIDTH, LOGO_HEIGHT, 1);
        display.display();
        break;
      case DIR_NEAR:
        Serial.println("NEAR");
        display.clearDisplay();
        display.drawBitmap(31, 0, mynear, LOGO_WIDTH, LOGO_HEIGHT, 1);
        display.display();
        break;
      case DIR_FAR:
        Serial.println("FAR");
        display.clearDisplay();
        display.drawBitmap(31, 0, myfar, LOGO_WIDTH, LOGO_HEIGHT, 1);
        display.display();
        break;
      default:
        Serial.println("NONE");
    }
  }
}

🧿 毕设项目分享:见文末!

5 最后

  • 14
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值