Can anyone please tell me the syntax to use an array of pins to be configured for sampling? I know how to deal with single pins as samplers but I could not find syntax for multiple pins. I tried a few things but it gives me syntax error. How do I program the imp to tell it that I need three pins (eg. pin 1,2,5) to sample data for a certain period?
Oh, we should probably have more explicit documentation of that. But basically, where our existing examples say:
hardware.sampler.configure(hardware.pin2, 1000, [buffer1, buffer2], samplesReady);
you should instead put:
hardware.sampler.configure([hardware.pin1, hardware.pin2, hardware.pin5], 1000, [buffer1, buffer2], samplesReady);
Peter
Thank you for replying. I had tried that but I am still getting an error in the logs.
My code is :-
buffer1 <- blob(6000);
buffer2 <- blob(6000);
hardware.sampler.configure(hardware.pin1, hardware.pin2, hardware.pin5, 1000, [buffer1, buffer2], samplesReady);
hardware.sampler.start();
The error log:-
2015-08-13 15:22:20 UTC-4 [Device] ERROR: bad parameters to sampler.configure(pin, sampleRateHz, buffers, callback[, processors])
2015-08-13 15:22:20 UTC-4 [Device] ERROR: at main:79
2015-08-13 15:22:25 UTC-4 [Status] Device disconnected
Could you please help me with this?
That’s not the same, though: check out the square brackets around the sequence of pins, turning it into an array.
Peter
Thank you, it works now.