Hey fellas...
Here comes this week's update, something I wanted to do for a long time, but the Upcycle Challenge made me to do it
...
I wanted to re-purpose the Omron D6T, I2C MEMS IR sensor to track movement and direction. The one I'm using here is Omron D6T-8L, with 8 pixels.
How its works:
The sensor has a resolution of 1x8, what I've done is read all the 8 pixel values and find the largest of it and the corresponding pixel and map the value to a Servo.
The Setup:
Connections
Omron D6T EDISON
SCL --> SCL
SDA --> SDA
5V --> 5V
GND --> GND
Servo Edison
Signal --> Any PWM pin
5V --> 5V
GND --> GND
The Code :
#include <Servo.h>
#include <Wire.h>
#define D6T_addr 0x0A // Address of OMRON D6T is 0x0A in hex
#define D6T_cmd 0x4C // Standard command is 4C in hex
Servo myservo;
int tmax, imax;
int numbytes = 19;
int numel = 8;
int rbuf[19];
int tdata[8];
float t_PTAT;
int deg;
int i;
void setup()
{
Wire.begin();
Serial.begin(9600);
myservo.attach(5);
myservo.write(90);
}
void loop()
{
tmax = 0;
imax=0;
Wire.beginTransmission(D6T_addr);
Wire.write(D6T_cmd);
Wire.endTransmission();
delay(70);
Wire.requestFrom(D6T_addr, numbytes); // D6T-8 returns 19 bytes
if (0 <= Wire.available()) { // If there is data still left in buffer
i = 0;
for (i = 0; i < numbytes; i++) {
rbuf[i] = Wire.read();
}
t_PTAT = (rbuf[0] + (rbuf[1] << 8) ) * 0.1;
for (i = 0; i < numel; i++) {
tdata[i] = (rbuf[(i * 2 + 2)] + (rbuf[(i * 2 + 3)] << 8 )) * 0.1;
//Serial.print(tdata[i]);
//Serial.print(",");
}
//Serial.println();
}
for (i = 0; i < numel; i++)
{
if (tmax <= tdata[i])
{ tmax = tdata[i];
imax = i;
Serial.println(imax);
}
}
deg = map(imax, 0, 7, 60 , 120);
myservo.write(deg);
delay(10);
}
Lets Track...
I made a simple mechanism to make the eyes move, i thought of 3d printing them but old acrylic pieces and a few match sticks came handy. also mounted with the skull.
You guys will be meeting Funeka mostly my 28th
Here's some sneak peek




Top Comments