OK, I've used the sketch with the delay, not the state machine, and it seems to be running at full speed on my Mega. I didn't install all the LEDs, I just added another output pin and put an LED in that, to be flashed at the end of the loop(). I also tested whether the Pin1 (TX) use was causing a problem-- doesn't appear to be, runs fine using it.
// Sequencing outputs w/variable speed pot // For original Pierre Cotnoir DZ Generator // // To be amended to 30 pole for GotoLuc replication // To Do: What do the top 2 LED's do, next to the Mega2560 ?
// TX LED will flash to pot rate, because is also Pin 1
// Pierre quote - the goal being not to turn off the stream // only move it ex: 1 on, 2 on, 1 off, 3 on, 2 off etc.
// Slider2732 March 2018
/* Example, Position 9 1 2 3 4 |5 6 7 8 9 10 11 A | * B * | C | * D | * E * |
7 6 5 4 3 2 1 14 13 12 11 10 9 8 21 20 19 18 17 16 15 28 27 26 25 24 23 22 35 34 33 32 31 30 29 */
int counter = 0; int switchspeed = 0;
void setup() { pinMode(A7, INPUT); // variable speed pot for (counter = 1; counter <=40; counter ++) { pinMode(counter, OUTPUT); } pinMode(51, OUTPUT); // inserted by TK for debugging }
void loop() { switchspeed = analogRead(A7); // make range usable with a map switchspeed = map(switchspeed, 0, 1023, 0, 100);
//Position 11 digitalWrite (1, HIGH); // A digitalWrite (40, HIGH); // B digitalWrite (17, HIGH); // C digitalWrite (40, HIGH); // D digitalWrite (35, HIGH); // E delay(switchspeed); // Switch off position 1 digitalWrite (40, LOW); // A digitalWrite (14, LOW); // B digitalWrite (16, LOW); // C digitalWrite (40, LOW); // D digitalWrite (34, LOW); // E
//Position 10 digitalWrite (2, HIGH); // A digitalWrite (40, HIGH); // B digitalWrite (18, HIGH); // C digitalWrite (22, HIGH); // D digitalWrite (0, HIGH); // E delay(switchspeed); // Switch off position 11 digitalWrite (1, LOW); // A digitalWrite (40, LOW); // B digitalWrite (17, LOW); // C digitalWrite (40, LOW); // D digitalWrite (35, LOW); // E
//Position 9 digitalWrite (3, HIGH); // A digitalWrite (40, HIGH); // B digitalWrite (19, HIGH); // C digitalWrite (23, HIGH); // D digitalWrite (40, HIGH); // E delay(switchspeed); // Switch off position 10 digitalWrite (2, LOW); // A digitalWrite (40, LOW); // B digitalWrite (18, LOW); // C digitalWrite (22, LOW); // D digitalWrite (40, LOW); // E
//Position 8 digitalWrite (4, HIGH); // A digitalWrite (40, HIGH); // B digitalWrite (20, HIGH); // C digitalWrite (24, HIGH); // D digitalWrite (40, HIGH); // E delay(switchspeed); // Switch off position 9 digitalWrite (3, LOW); // A digitalWrite (40, LOW); // B digitalWrite (19, LOW); // C digitalWrite (23, LOW); // D digitalWrite (40, LOW); // E
//Position 7 digitalWrite (5, HIGH); // A digitalWrite (8, HIGH); // B digitalWrite (21, HIGH); // C digitalWrite (25, HIGH); // D digitalWrite (40, HIGH); // E delay(switchspeed); //Switch off position 8 digitalWrite (4, LOW); // A digitalWrite (40, LOW); // B digitalWrite (20, LOW); // C digitalWrite (24, LOW); // D digitalWrite (40, LOW); // E
//Position 6 digitalWrite (6, HIGH); // A digitalWrite (9, HIGH); // B digitalWrite (40, HIGH); // C digitalWrite (26, HIGH); // D digitalWrite (29, HIGH); // E delay(switchspeed); // Switch off position 7 digitalWrite (5, LOW); // A digitalWrite (8, LOW); // B digitalWrite (21, LOW); // C digitalWrite (25, LOW); // D digitalWrite (40, LOW); // E
//Position 5 digitalWrite (7, HIGH); // A digitalWrite (10, HIGH); // B digitalWrite (40, HIGH); // C digitalWrite (27, HIGH); // D digitalWrite (30, HIGH); // E delay(switchspeed); // Switch off position 6 digitalWrite (6, LOW); // A digitalWrite (9, LOW); // B digitalWrite (40, LOW); // C digitalWrite (26, LOW); // D digitalWrite (29, LOW); // E
//Position 4 digitalWrite (40, HIGH); // A digitalWrite (11, HIGH); // B digitalWrite (40, HIGH); // C digitalWrite (28, HIGH); // D digitalWrite (31, HIGH); // E delay(switchspeed); // Switch off position 5 digitalWrite (7, LOW); // A digitalWrite (10, LOW); // B digitalWrite (40, LOW); // C digitalWrite (27, LOW); // D digitalWrite (30, LOW); // E
//Position 3 digitalWrite (40, HIGH); // A digitalWrite (12, HIGH); // B digitalWrite (40, HIGH); // C digitalWrite (40, HIGH); // D digitalWrite (32, HIGH); // E delay(switchspeed); // Switch off position 4 digitalWrite (40, LOW); // A digitalWrite (11, LOW); // B digitalWrite (40, LOW); // C digitalWrite (28, LOW); // D digitalWrite (31, LOW); // E
//Position 2 digitalWrite (40, HIGH); // A digitalWrite (13, HIGH); // B digitalWrite (15, HIGH); // C digitalWrite (40, HIGH); // D digitalWrite (33, HIGH); // E delay(switchspeed); // Switch off position 3 digitalWrite (40, LOW); // A digitalWrite (12, LOW); // B digitalWrite (40, LOW); // C digitalWrite (40, LOW); // D digitalWrite (32, LOW); // E
// Position 1 digitalWrite (40, HIGH); // A digitalWrite (14, HIGH); // B digitalWrite (16, HIGH); // C digitalWrite (40, HIGH); // D digitalWrite (34, HIGH); // E delay(switchspeed); // Switch off position 2 digitalWrite (40, LOW); // A digitalWrite (13, LOW); // B digitalWrite (15, LOW); // C digitalWrite (40, LOW); // D digitalWrite (33, LOW); // E
// // inserted by TK for debugging // digitalWrite (51, HIGH); delay(5); digitalWrite (51, LOW); //
}
So I'm thinking either you got a bogus Mega, or there is something wrong with your external circuit or the connections of the speed pot, maybe.
|