DFRobot DFR0274 Скачать руководство пользователя страница 8

  while(pulseIn(IR_PIN, HIGH) < BIT_START); 
  
  read_pulse(pulse); 
  pulse_to_bits(pulse, bits); 
  RemoteVerify(bits); 
  return bits_to_int(bits); 

  
  
/* 
  use pulseIn to receive IR pulses from the remote. 
  Record the length of these pulses (in ms) in an array 
*/ 
  
void read_pulse(int pulse[]) 

  for (int i = 0; i < IR_BIT_LENGTH; i++) 
  { 
    pulse[i] = pulseIn(IR_PIN, HIGH); 
  } 

  
/* 
  IR pulses encode binary "0" as a short pulse, and binary "1" 
  as a long pulse.  Given an array containing pulse lengths, 
  convert this to an array containing binary values 
*/ 
  
void pulse_to_bits(int pulse[], int bits[]) 

  if (debug) { Serial.println("-----"); } 
  for(int i = 0; i < IR_BIT_LENGTH; i++)  
  { 
    if (debug) { Serial.println(pulse[i]); } 
    if(pulse[i] > BIT_1) //is it a 1? 
    { 
      bits[i] = 1; 
    }   
    else if(pulse[i] > BIT_0) //is it a 0? 
    { 
      bits[i] = 0; 
    }  
    else //data is invalid... 
    { 
      Serial.println("Error"); 
    } 
  } 

  
/* 
  check returns proper first 14 check bits 
*/ 
  
void RemoteVerify(int bits[]) 

  int result = 0; 
  int seed = 1; 

Downloaded from

Arrow.com.

Downloaded from

Arrow.com.

Downloaded from

Arrow.com.

Downloaded from

Arrow.com.

Downloaded from

Arrow.com.

Downloaded from

Arrow.com.

Downloaded from

Arrow.com.

Downloaded from

Arrow.com.

Содержание DFR0274

Страница 1: ...rs differently You can also control the RGB LED Strip Driver Shield by the IR remote controller The RGB LED Strip Driver Shield connects to an Arduino board using long wire wrap headers which extend t...

Страница 2: ...ng Pin D4 IR data receiving PS This feature could be disable by removing the jumper cap on the shield Note 1 Commonly we use the common anode RGB LED Strip So when connecting the RGB Strip to the driv...

Страница 3: ...olor int red int green int blue analogWrite RedPin red analogWrite GreenPin green analogWrite BluePin blue void setup pinMode RedPin OUTPUT Init Arduino driving pins pinMode GreenPin OUTPUT pinMode Bl...

Страница 4: ...i setColor 0 255 i i delay 10 IR Receiving Code For the ir receiving feature we recommend to use Arduino IRRemote library created by Ken Shirriff This library is quite easy to use and directly support...

Страница 5: ...up Serial begin 9600 irrecv enableIRIn Start the receiver void loop if irrecv decode results Serial println results value HEX irrecv resume Receive the next value IR Remote control Demo Use IR transmi...

Страница 6: ...IT_0 450 Binary 0 threshold Microseconds define BIT_START 4000 Start bit threshold Microseconds define IR_PIN 4 IR Sensor pin define LED_PIN 13 LED goes off when signal is received int debug 0 flag as...

Страница 7: ...ite BluePin Blue_Bright else analogWrite BluePin 0 if Red_flag analogWrite RedPin Red_Bright else analogWrite RedPin 0 if Green_flag analogWrite GreenPin Green_Bright else analogWrite GreenPin 0 delay...

Страница 8: ...lse lengths convert this to an array containing binary values void pulse_to_bits int pulse int bits if debug Serial println for int i 0 i IR_BIT_LENGTH i if debug Serial println pulse i if pulse i BIT...

Страница 9: ...er int bits_to_int int bits int result 0 int seed 1 Convert bits to integer for int i IR_BIT_LENGTH FirstLastBit i IR_BIT_LENGTH i if bits i 1 result seed seed 2 return result respond to specific remo...

Страница 10: ...croll down tests if Blue_flag true Blue_Bright 10 Blue_Bright 10 if Red_flag true Red_Bright 10 Red_Bright 10 if Green_flag true Green_Bright 10 Green_Bright 10 Serial println v break case 31365 scrol...

Страница 11: ...t 120 Serial println 3 break case 30090 4 Flash_flag true Serial println 4 break case 29962 5 Serial println 5 break case 29835 6 Serial println 6 break case 29580 7 Serial println 7 break case 29452...

Страница 12: ...aded from Arrow com Downloaded from Arrow com Downloaded from Arrow com Downloaded from Arrow com Downloaded from Arrow com Downloaded from Arrow com Downloaded from Arrow com Downloaded from Arrow co...

Отзывы: