https://github.com/adafruit/Adafruit_NeoPixel
Please refer below for product details.
#include
#include
#include
int sensePin= A1;
unsigned char cmd;
DFRobot_Gesture myGesture;
#define DIN A0
Adafruit_NeoPixel led = Adafruit_NeoPixel(64, DIN, NEO_GRB + NEO_KHZ800);
int LR = 5;
int eyelid = 0;
int whiteNum = 52;
int blackNum = 20;
int pupilNum = 12;
//white eye
int whiteLED[52] = { 2, 3, 4, 5, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 58, 59, 60, 61};
//black eye
int blackLED[11][20] = {{50, 51, 52, 53, 58, 61, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64},
{42, 43, 44, 45, 49, 50, 53, 54, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64},
{34, 35, 36, 37, 41, 42, 45, 46, 49, 54, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64},
{26, 27, 28, 29, 33, 34, 37, 38, 41, 46, 54, 49, 58, 61, 61, 64, 64, 64, 64, 64},
{18, 19, 20, 21, 25, 26, 29, 30, 33, 38, 41, 46, 49, 50, 53, 54, 58, 59, 60, 61},
{10, 11, 12, 13, 17, 18, 21, 22, 25, 30, 33, 38, 41, 42, 45, 46, 50, 51, 52, 53},
{ 2, 3, 4, 5, 9, 10, 13, 14, 17, 22, 25, 30, 33, 34, 37, 38, 42, 43, 44, 45},
{ 2, 5, 9, 14, 17, 22, 25, 26, 29, 30, 34, 35, 36, 37, 64, 64, 64, 64, 64, 64},
{ 9, 14, 17, 18, 21, 22, 26, 27, 28, 29, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64},
{ 9, 10, 13, 14, 18, 19, 20, 21, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64},
{ 2, 5, 10, 11, 12, 13, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64}};
//pupil
int pupilLED[11][12] = {{59, 60, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64},
{51, 52, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64},
{43, 44, 50, 51, 52, 53, 58, 59, 60, 61, 64, 64},
{35, 36, 42, 43, 44, 45, 50, 51, 52, 53, 59, 60},
{27, 28, 34, 35, 36, 37, 42, 43, 44, 45, 51, 52},
{19, 20, 26, 27, 28, 29, 34, 35, 36, 37, 43, 44},
{11, 12, 18, 19, 20, 21, 26, 27, 28, 29, 35, 36},
{ 3, 4, 10, 11, 12, 13, 18, 19, 20, 21, 27, 28},
{ 2, 3, 4, 5, 10, 11, 12, 13, 19, 20, 64, 64},
{ 2, 3, 4, 5, 11, 12, 64, 64, 64, 64, 64, 64},
{ 3, 4, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64}};
//eyelid
int eyelidNum[8] = {0,4,8,14,20,28,36,44};
int eyelidLED[56] = {23, 24, 39, 40, 22, 25, 38, 41, 9, 21, 26, 37, 42, 54, 10, 20, 27, 36, 43, 53, 5, 11,
19, 28, 35, 44, 52, 58, 4, 12, 18, 29, 34, 45, 51, 59, 3, 13, 17, 30, 33, 46, 50, 60};
void setup(){
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(115200); // start serial for output
pinMode(sensePin, INPUT);
led.begin();
led.setBrightness(100); //LED brightness 0-255
blink(LR, eyelid);
}
void loop(){
if(digitalRead(sensePin)==0){
myGesture.I2C1_MasterRead(md.buf,26,0x42); //The address is:0x42
cmd = myGesture.mgcProcMsg(); //process the message
if(cmd != GI_NOGESTURE ){
switch(cmd){
case GI_FLICK_R:
Serial.println("RIGHT");
//Move the eye right
for(int i = LR; i <= 10; i++){
blink(i, eyelid);
delay(100);
}
LR = 10;
break;
case GI_FLICK_L:
Serial.println("LEFT");
//Move the eye left
for(int i = LR; i >= 0; i--){
blink(i, eyelid);
delay(100);
}
LR = 0;
break;
case GI_FLICK_D:
Serial.println("DOWN");
//Eyelid close
for(int i = eyelid; eyelid <= 8; eyelid++){
blink(LR, eyelid);
delay(100);
}
eyelid = 8;
break;
case GI_FLICK_U:
Serial.println("UP");
//Eyelid open
for(int i = eyelid; eyelid >= 0; eyelid--){
blink(LR, eyelid);
delay(100);
}
eyelid = 0;
break;
case GI_AIRWHEEL_CW://Clockwise in circles
Serial.println("CW");
//Return eye to the front
Return();
break;
case GI_AIRWHEEL_CCW://Counterclockwise circles
Serial.println("CCW");
//Return eye to the front
Return();
break;
default: break;
}
}
}
}
void blink( int LR, int eyelid) {
if (eyelid != 8){
//white eye
for(uint16_t i=0; i= 5; i--){
blink(i, eyelid);
delay(100);
}
}
LR = 5;
}