How to send bytes to CM1101 co2 sensor from arduino

I have to send 0x11, 0x01, 0x01, 0xED to the co2 sensor consequently then the co2 sensor will send me response data

To send the data
before setup loop I define
pattern []=[0x11, 0x01, 0x01, 0xED];

then in the setup loop I write

no=0;
while(no<=3){
for(int i=0; i<8; i++){
boolean on_off=bitread(pattern[no], i);
digitalWrite(4, on_off);} no++;}//4th pin configuration

does this code transmit 0x11, 0x01, 0x01, 0xED in this order to the sensor?

if not could anyone provide me a code for it? I am desperate.

the specifications of the co2 sensor is http://www.eleparts.co.kr/EPXDC8CV
please help

Lohaness1000:
does this code transmit 0x11, 0x01, 0x01, 0xED in this order to the sensor?

No.

Ask yourself what does the bitRead( ) function do, and why do you need it in your sketch.

I dont know what bitread does. I just read it from the book please correct my code if possible. So that i can transmit the 4bytes

It communicates using a serial line. Just connect to it with the serial line from the Arduino or SoftwareSerial if your serial line is already in use for something else.

It's always better to just read the datasheet and specs for a device than to try to "figure out" how to communicate with it.

for(int i=0; i<4; i++){
    Serial.write(pattern[i]);
}

I dont know what bitread does.

It's ,documented on the reference page. Learn what it does.

Then how can i connect the pin if it is serial write mode. Is it possible to read from the sensor using Serialread too will the sensor detect signals by using serialwrite

I have to set input and output pins then they will do serial communication right only one output and only one input

does this code transmit 0x11, 0x01, 0x01, 0xED in this order to the sensor?

Sort of. It outputs the byte's 1' and 0's with the lsb first.

I doubt you will have much success trying to bit bang serial output on pin 4. You do not have start and stop bits, and are not controlling the baud rate. There are possible endian issues between the sensor and Arduino, and don't know if you have your bit output in the correct order for the sensor.

You should be using a hardware serial port or software serial. You might want to us an Arduino with multiple hardware serial ports