RuiViana

SeparaEjunta.ino

Dec 9th, 2018
148
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. void setup() {
  4.   Serial.begin(115200);
  5.   int myValor = 15000;
  6.   int byteLow = myValor & 0x00FF;
  7.   int byteHigh = (myValor >> 8 ) & 0x00FF;
  8.   Serial.print("myValor: "); Serial.println(myValor);
  9.   Serial.println("Separando");
  10.   Serial.print("myValor, HEX: "); Serial.println(myValor, HEX);
  11.   Serial.print("byteLow: "); Serial.println(byteLow, HEX);
  12.   Serial.print("byteHigh: "); Serial.println(byteHigh, HEX);
  13.  
  14.   Serial.println("Juntando");
  15.  
  16.   int ValorRecomposto = byteHigh;
  17.   ValorRecomposto = (ValorRecomposto << 8 ) | byteLow;
  18.   Serial.print("ValorRecomposto HEX: "); Serial.println(ValorRecomposto, HEX);
  19.   Serial.print("ValorRecomposto: "); Serial.println(ValorRecomposto);
  20.  
  21. }
  22.  
  23. void loop() {
  24. }
RAW Paste Data