| Electronic Components Datasheet Search |
|
DFR0305 Datasheet(PDF) 6 Page - DFROBOT |
|
|
|||||||||||||||||||||||||||||
DFR0305 Datasheet(HTML) 6 Page - DFROBOT |
|
6 / 18 page ![]() The code is as follows: int led = 13; char rcv_buf[10]; // Receive command arrays. void setup() { pinMode(led, OUTPUT); Serial.begin(115200); } void loop() { int data_len=0; while(1) { while(Serial.available()) { rcv_buf[(data_len++)%10] =Serial.read(); } if(rcv_buf[data_len-2]== '\r' && rcv_buf[data_len-1]=='\n') // Stop reading the serial once getting the ending command. break; } if ((data_len==4)&&(!strncmp(rcv_buf,"ON",2))) // Open the light L when the command is "ON". { digitalWrite(led, HIGH); // Set D13 pin as high and openg the light L Serial.println("LIHGT ON"); }else if((data_len==5)&&(!strncmp(rcv_buf,"OFF",3))) // Close the light L when the command is "OFF". { digitalWrite(led, LOW); // Set D13 pin as low and the light L Serial.println("LIHGT OFF"); } } if ((data_len==4)&&(!strncmp(rcv_buf,"ON",2))) // Open the light L whe n the command is "ON". { digitalWrite(led, HIGH); // Set D13 pin as high and openg the light L Serial.println("LIHGT ON"); }else if((data_len==5)&&(!strncmp(rcv_buf,"OFF",3))) // Close the light L when the command is "OFF". { digitalWrite(led, LOW); // Set D13 pin as low and the light L Serial.println("LIHGT OFF"); } |
|
|
Link URL |
| Does ALLDATASHEET help your business so far? [ DONATE ] |
About Alldatasheet | Advertisement | Contact us | Privacy Policy | Link to Datasheet | Link Exchange | Manufacturer List All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |