Somatosensory TV Remote Controller
From Microduino Wiki
Language: | English • 中文 |
---|
ContentsObjectiveTo have a remote control of a TV through somatosensory operation. By moving the position of the remote controller, you can change TV channels or volume. PrincipleUse three-axis acceleration sensor MPU6050 to detect the remote controller's movement and the infrared transmission sensor to control the TV by matching code. Equipment
Hardware Buildup
Software Debugging
#define ITEM+ 0x02FDD827 //TV program+
#define ITEM- 0x02FDF807 // TV program -
#define VOL+ 0x02FD58A7 //Volume+
#define VOL- 0x02FD7887 // Volume -
MPU6050 accelgyro; //Three-axis acceleration sensor
IRsend irsend; //Infrared transmission
Serial.println("Initializing I2C devices...");
accelgyro.initialize(); //IIC device initializes.
Serial.println("Testing device connections...");
Serial.println(accelgyro.testConnection() ?"MPU6050 connection successful" : "MPU6050 connection failed"); //MPU6050 has been connected.
accelgyro.getAcceleration(&ax, &ay, &az); //Acquire accelerator values.
Ax = ax/16384.00;
Ay = ay/16384.00;
Az = az/16384.00;
if(Ay >= 0.6 ) //Have detected the remote controller starts to move rightwards.
{
irsend.sendNEC(ITEM+,32); //Send channel change code
delay(1000); //Delay time and wait until it stops moving.
}
else if(Ay <= -0.6) //Have detected the remote controller starts to move leftwards.
{
irsend.sendNEC(ITEM-,32);
delay(1000);
}
else if(Az >= 1.5) //Have detected the controller starts to move upwards.
{
irsend.sendNEC(VOL+,32);
delay(1000);
}
else if(Az <= 0.5) //Have detected the controller starts to move downwards.
{
irsend.sendNEC(VOL-,32);
delay(1000);
}
delay(100);
ProgramResultBy moving leftwards or rightwards, the remote controller can change TV channels. By moving upwards or downwards, it can control TV volume. You can also add attitudes to control TV's other functions. Video |