Go Down

Topic: how to send lines of bytes?  (Read 275 times) previous topic - next topic

mojanen

Aug 08, 2016, 05:27 pm Last Edit: Aug 08, 2016, 05:33 pm by mojanen
I try to make copy of one device and i'm stuck.




I need to get arduino send this looking line of bytes out of digital pin.

(start-bit 01001001 stop-bit, start-bit 01010010 stop bit, start-bit 10100111 stop-bit, start-bit 00111010 stop-bit).

I'm not sure what is best command to use.

Robin2

Sounds like a job for Serial.write() or, perhaps, for SoftwareSerial.

However as you have not posted your program or described what you are trying to achieve I am only guessing.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

mojanen

I try to make receiver control arduino and arduino control Sony's camera.

here is my code so far.

unsigned long timer[5];
byte last_channel[4];
int input[4];
byte transmit = 7;
byte data[]= {2, 50, 172}; //value to transmit, binary
byte mask = 1; //our bitmask


void setup() {
  PCICR |= (1 << PCIE0);
  Serial.begin(9600);
   pinMode(transmit,OUTPUT);

}

void loop() {
  print();
}

ISR(PCINT0_vect) {
  timer[0] = micros();

  // channel 1 ---------------

  if(last_channel[0] == 0 && PINB & B00000001 ) {
    last_channel[0] = 1;
 for (mask = 00000001; mask>0; mask <<= 1) { //iterate through bit mask
    if (data[0,1,2] & mask){ // if bitwise AND resolves to true
      digitalWrite(transmit,HIGH); // send 1
    }
    else{ //if bitwise and resolves to false
      digitalWrite(transmit,LOW); // send 0
    }
 
  }
   
    timer[1] = timer[0];
  }


  else if(last_channel[0] == 1 && !(PINB & B00000001) ) {
    last_channel[0] = 0;
    input[0] = timer[0] - timer[1];
  }

Robin2

I try to make receiver control arduino and arduino control Sony's camera.
You need to tell us what you mean by "receiver", how it is connected to the Arduino and what data it sends to the Arduino.

You also need to provide details of the interface with the camera - a link to the datasheet is best.

...R

Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up