IR control CASIO projector

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
Post Reply
smartazz
Posts: 4
Joined: 20 Feb 2017 20:22

IR control CASIO projector

Post by smartazz » 08 Jun 2017 00:16

Hi. I use this example code for control my CASIO projector.
Firstly I scan my controller code:

RAW16_data[38]= {0x25, 0x1F5, 0x681, 0x259, 0x67D, 0x254, 0x682, 0x258, 0x67E, 0x252, 0x21B, 0x252, 0x684, 0x256, 0x217, 0x256, 0x216, 0x257, 0x216, 0x257, 0x215, 0x258, 0x215, 0x258, 0x214, 0x259, 0x67C, 0x254, 0x219, 0x254, 0x681, 0x259, 0x67D, 0x253, 0x682, 0x258, 0x67F, 0x251}

Then I it write in code:


#include "IRController.h"

IRTransmitterParams ir_transmitter(byte(IR_TRANSMITTER_OUTPUT_PIN6),
IR_FLAGS_OUTPUT_HIGHDRIVE,
IR_MS_PRESCALLER_4MHZ,
IR_CARRIER_PRESCALLER_8MHZ);

#define SWITCH_ON 0xff
#define SWITCH_OFF 0

// Use IRScanner.ino as IR-sniffer
// This codes were shiffed from SONY TV IR remote control
word raw_command_on[] ={0x25, 0x1F5, 0x681, 0x259, 0x67D, 0x254, 0x682, 0x258, 0x67E, 0x252, 0x21B, 0x252, 0x684, 0x256, 0x217, 0x256, 0x216, 0x257, 0x216, 0x257, 0x215, 0x258, 0x215, 0x258, 0x214, 0x259, 0x67C, 0x254, 0x219, 0x254, 0x681, 0x259, 0x67D, 0x253, 0x682, 0x258, 0x67F, 0x251};
word raw_command_off[] = {0x19, 0x987, 0x24B, 0x4C0, 0x248, 0x267, 0x249, 0x4C2, 0x247, 0x268, 0x248, 0x4C3, 0x245, 0x269.
0x246, 0x268, 0x248, 0x4C3, 0x245, 0x26A, 0x246, 0x269, 0x247, 0x267, 0x249, 0x266};

// Detected vendor
#define MY_IR_VENDOR IR_VENDOR_SONY // Use SONY protocol. See IRController.h for more details.
// Decoded commands
#define MY_IR_VENDOR_CMD_ON 0x290
#define MY_IR_VENDOR_CMD_OFF 0x290
#define DECODED_COMMAND_NBITS 12

// Last saved values on channels
byte currentCh1 = 0;
byte currentCh2 = 0;

// Command to send via IR
byte current_cmd = 0;
IRCommand_t vendor_cmd;

ZUNO_SETUP_CHANNELS(
ZUNO_SWITCH_BINARY(getter1, setter1),
ZUNO_SWITCH_BINARY(getter2, setter2)
);

void setup() {
// We have to setup IRLED pin as output
pinMode(6, OUTPUT);
digitalWrite(6, LOW);

// setting up IR-controller as IR-transmitter
ir_transmitter.setupVendor(MY_IR_VENDOR);
IR.begin(&ir_transmitter);

vendor_cmd.vendor = MY_IR_VENDOR;
vendor_cmd.n_bits = DECODED_COMMAND_NBITS;

}

void sendRAWCommand(WORD * raw16) {
// we have to repeat packet like another IR-controllers do
byte count = 7;
while(count--) {
IR.send_raw16(raw16);
delay(30);
}
}

void sendVendorCommand(unsigned long cmd) {
// we have to repeat packet like another IR-controllers do
byte count = 7;
while(count--) {
vendor_cmd.data[0] = cmd;
IR.sendCommand(&vendor_cmd);
delay(30);
}
}

void loop() {
switch(current_cmd) {
case 1:
sendRAWCommand(raw_command_on);
break;
case 2:
sendRAWCommand(raw_command_off);
break;
case 3:
sendVendorCommand(MY_IR_VENDOR_CMD_ON);
break;
case 4:
sendVendorCommand(MY_IR_VENDOR_CMD_OFF);
break;
default:
// nothing to do
break;
}
current_cmd = 0;

delay(500);
}

void setter1(byte value) {
if (value != SWITCH_OFF) {
current_cmd = 1; // will be dispatched in the next loop
} else {
current_cmd = 2;
}
// let's save our value for the situation, when the controller will ask us about it
currentCh1 = value;
}

byte getter1() {
return currentCh1;
}

void setter2(byte value) {
if (value != SWITCH_OFF) {
current_cmd = 3;
} else {
current_cmd = 4;
}
currentCh2 = value;
}

byte getter2() {
return currentCh2;
}


It work and send signal, but it didn't turn on or turn off my projector.
Where is problem in code? My controller use 38 kHz.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 3 guests