on Infrared Received Number

Run some code when a number from a data message comes into the infrared receiver.

network.onInfraredReceivedNumber(function (num) {

})

The infrared receiver gets a data message sent from another board. The message is called a packet. The packet has both the data from the sender and some other information used to help transmit the data correctly between the boards. You only need to know what the program on the other board wants to send you so your program just receives the data part of the packet.

Parameters

  • handler: the function that has the code to run when the infrared data message is received. This function has one argument:
  • num: a single number value received from the sender.

Example

Show the value of a number received from an infrared data message in the console log.

network.onInfraredReceivedNumber(function (num) {
    if (num > 0) { 
        console.log("Infrared msg: " + num)
    } 
})

See also

infrared send number

infrared