int pulseWidth = variable/different for all pwm channels
hello
i'm bit of noob here i'am working on project define the 'int pulsewidth = '
per pwm channel.
is possible?
in code below can see its's same channels.
maybe can show me how 2 or 3 changeable channels of code looks , can copy paste them
thnx
kind regards
william
unsigned long time;
unsigned long timeinarray[8];
int pulsewidth = 80;
#include <servo.h>
void setup() {
// initialize both serial ports:
serial.begin(9600);
pinmode(2, output);
pinmode(3, output);
pinmode(4, output);
pinmode(5, output);
pinmode(6, output);
pinmode(7, output);
pinmode(8, output);
pinmode(9, output);
}
void loop() {
// read port 1
unsigned long currentmillis = millis(); // huidige tijd in currentmillis
if (serial.available()) {
int inbyte = serial.read();
(int x = 1; x < 10; x++) {
if (inbyte == x+34) { // midi noot 36 t/m 43
digitalwrite(x, high); // stuurt high naar arduino pin 2 t/m 9
}
(int x = 1; x < 10; x++) {
if (inbyte == x+34) { // stop in de array het huidige tijdstip als er een note is
timeinarray[x-2] = currentmillis;
}
}
}
}
for (int x = 1; x < 10; x++) { if (timeinarray[x-2] != 0) {
if ( currentmillis - timeinarray[x-2] >= pulsewidth ) {
timeinarray[x-2] = 0; digitalwrite(x, low);
}
}
}
}
i'm bit of noob here i'am working on project define the 'int pulsewidth = '
per pwm channel.
is possible?
in code below can see its's same channels.
maybe can show me how 2 or 3 changeable channels of code looks , can copy paste them

kind regards
william
unsigned long time;
unsigned long timeinarray[8];
int pulsewidth = 80;
#include <servo.h>
void setup() {
// initialize both serial ports:
serial.begin(9600);
pinmode(2, output);
pinmode(3, output);
pinmode(4, output);
pinmode(5, output);
pinmode(6, output);
pinmode(7, output);
pinmode(8, output);
pinmode(9, output);
}
void loop() {
// read port 1
unsigned long currentmillis = millis(); // huidige tijd in currentmillis
if (serial.available()) {
int inbyte = serial.read();
(int x = 1; x < 10; x++) {
if (inbyte == x+34) { // midi noot 36 t/m 43
digitalwrite(x, high); // stuurt high naar arduino pin 2 t/m 9
}
(int x = 1; x < 10; x++) {
if (inbyte == x+34) { // stop in de array het huidige tijdstip als er een note is
timeinarray[x-2] = currentmillis;
}
}
}
}
for (int x = 1; x < 10; x++) { if (timeinarray[x-2] != 0) {
if ( currentmillis - timeinarray[x-2] >= pulsewidth ) {
timeinarray[x-2] = 0; digitalwrite(x, low);
}
}
}
}
why want different pulse widths?
Arduino Forum > Using Arduino > Programming Questions > int pulseWidth = variable/different for all pwm channels
arduino
Comments
Post a Comment