Controlling two attiny85s with one footswitch

Started by patrick398, December 12, 2020, 03:44:52 AM

Previous topic - Next topic

patrick398

Quote from: pruttelherrie on December 20, 2020, 12:45:33 PM
Actually, you could try that first yeah!  After all the setup, the modeswitching could be as simple as

if(mode1) {
  pinMode(1, INPUT);
} else {
  pinMode(1, OUTPUT);
}

If that doesn't work, you'll have to turn off the interrupts in mode1 and then turn them on in mode2, something like

if(mode1) {
  TIMSK = TIMSK & ~(1<<OCIE0A);              // Disable interrupt
  GIMSK = GIMSK & ~(1<<PCIE);                // Disable pin change interrupt
} else {
  TIMSK = TIMSK | 1<<OCIE0A;              // Enable interrupt
  GIMSK = GIMSK | 1<<PCIE;                // Enable pin change interrupt
}


Read up on 'bit manipulation' to learn how & why this works! For example (quick google) https://www.avrfreaks.net/forum/tut-c-bit-manipulation-aka-programming-101


If I had a Christmas card list, you would have just made the cut! Thanks so much for that man, looking forward to trying it out. And I'll try and wrap my tiny mind around bit manipulation. I've always thought I should be manipulating more bits

pruttelherrie