Hi, I would like to add additional transducers to the set of code that I am doing now, and it needs to be inside the for loop.
So simply to say, when I trigger a command, it needs to go through the loop. A particle would be used and it has to move through a series of transducers. Currently able to move through one pair of transducers only, and I would like to move it through 2 or 3 pairs of transducers minimally.
Seeking for help please.
`#include <pwmWrite.h>
#include <Servo.h>
const int pwmPin[8] = { 13, 14, 15, 16, 17, 18, 19, 22 };
const uint16_t duty = 512; //50% duty
const uint16_t deadtime = 10;
const uint16_t phase[5] = { 0, 256 , 512, 768, 1024}; //0 and 90 degree phase shift. 256=90, 512 = 180.
const uint16_t shift[2] = { 42, 42 };
const uint32_t frequency = 40000;
const byte resolution = 10;
Pwm pwm = Pwm();
void setup() {
Serial.begin(115200);
pwm.pause();
pwm.resume();
pwm.printDebug();
}
// Right side is Channel 14, Left side is Channel 13.
void loop() {
pwm.write(pwmPin[1], duty, frequency, resolution, phase[0]);
pwm.write(pwmPin[5], duty, frequency, resolution, phase[1]);
pwm.write(pwmPin[2], duty, frequency, resolution, phase[1]);
pwm.write(pwmPin[6], duty, frequency, resolution, phase[1]);
while (1) {
char command = Serial.read();
if (command == 'a') {
for (int i = 0; i<=1024; i++) {
pwm.write(pwmPin[1], duty, frequency, resolution, i);
delay(2);
}
}
}
}`