Setting ADC Channel

Setting an ADC channel is required to be set before using ADC. If you do not set this, a channel which has the same index of channel with the ADC device's index will be assigned. For example, Channel 0 is automatically assigned to ADC 0 as default channel. You can read ADC values from the channels sequentially by switching among channels.
To set channel or switch to another channel, use the following command:

pid_ioctl($pid, "set ch N"); // set channel

You can get current channel id by using following command:

pid_ioctl($pid, "get ch");       // get the current channel

Parameter N means the number of channel.

example of setting ADC channel

$pid = pid_open("/mmap/adc0");    // open ADC 0
pid_ioctl($pid, "set ch 1");      // set channel to 1
pid_ioctl($pid, "set ch 2");      // set channel to 2
echo pid_ioctl($pid, "get ch");   // print the current channel(output: 2)
pid_close($pid);                  // close ADC