| | |
| | | char dataToSend[4] = "TRG"; |
| | | |
| | | void IRAM_ATTR isr() { |
| | | digitalWrite(OUT_TRIGGER, HIGH); |
| | | radio.write( &dataToSend, sizeof(dataToSend) ); |
| | | delay(1); |
| | | // detachInterrupt(digitalPinToInterrupt(IN_TRIGGER)); |
| | | digitalWrite(OUT_TRIGGER,LOW); |
| | | long time=micros(); |
| | | while(micros()-time<4000); |
| | | digitalWrite(OUT_TRIGGER,HIGH); |
| | | // radio.write( &dataToSend, sizeof(dataToSend) ); |
| | | |
| | | // attachInterrupt(digitalPinToInterrupt(IN_TRIGGER), isr, RISING); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | radio.begin(); |
| | | radio.openWritingPipe(address); |
| | | radio.setPALevel(RF24_PA_MAX); |
| | | //radio.setDataRate( RF24_250KBPS ); |
| | | radio.setDataRate( RF24_250KBPS ); |
| | | |
| | | pinMode(IN_TRIGGER, INPUT_PULLUP); |
| | | //pinMode(IN_TRIGGER, INPUT_PULLUP); |
| | | pinMode(OUT_TRIGGER, OUTPUT); |
| | | attachInterrupt(IN_TRIGGER, isr, RISING); |
| | | |
| | | digitalWrite(OUT_TRIGGER,HIGH); |
| | | attachInterrupt(digitalPinToInterrupt(IN_TRIGGER), isr, FALLING); |
| | | Serial.begin(115200); |
| | | |
| | | } |
| | | |
| | | void loop() { |
| | | // put your main code here, to run repeatedly: |
| | | //radio.write( &dataToSend, sizeof(dataToSend) ); |
| | | // delay(5000); |
| | | Serial.print(micros()); |
| | | Serial.println(": ---> TRG"); |
| | | radio.write( &dataToSend, sizeof(dataToSend) ); |
| | | Serial.print(micros()); |
| | | Serial.println(": TRG--->"); |
| | | delay(5000); |
| | | |
| | | } |