Sketch is running on Uno, but not on ATtiny45


hi!

i'm struggling sketch runs on uno, not on attiny45. setup is: arduino isp, board attiny 45 @ 8 mhz, arduino ide 1.5.8 , attiny core installed.

there no errors when program bootloader on tiny , sketches blink, fade etc. working flawless on ports.

with sketch led on port 1 (pin6) lights when hit button , it's blinking when press button longer period.

i've tried different ports , 2 other attiny45 no luck. power supply stable etc.
back on uno (with other port settings), same sketch works charm.

any ideas?

code: [select]
//
//



int flash1 = 0; // front flash tiny: pin 5
int flash2 = 1; // mask flash tiny: pin 6
int button = 3; // camera flash trigger simulation tiny: pin 2
int trig;  // trigger state
int count; // flash switching
unsigned long prevmillis = 0;


//  bounce debouncer = bounce();

// setup routine runs once when press reset:
void setup() {
  // initialize digital pin output.
  pinmode(flash1, output);
  pinmode(flash2, output);
  pinmode(trig, input);
  count=0;
  digitalwrite(flash1, low);
  digitalwrite(flash2, low);
}


void loop() {

  trig = digitalread(button);
 
  // waiting first flash trigger signal
  if (trig == high && count == 0) {
   
    digitalwrite(flash1, high);
    delay (20);
    digitalwrite(flash1, low);
    prevmillis = millis(); 
   delay(200);
    count = 1; // switch mask flash

  }
 
  // if there second flash trigger within interval seconds, trigger freemask flash
  if (trig == high && count == 1) {
    digitalwrite(flash2, high);

    delay (20);
    digitalwrite(flash2, low);
    delay(200);
    count = 0; // switch first flash
 
  }     
  // fallback flash1 if no second trigger within 5 sec.
  if (millis() - prevmillis >= 5000 && count == 1) {
    count = 0;
    }
}

you working charm on uno, find problem here.

code: [select]

  if (trig == high && count == 0) {

    //....

    count = 1; // <<<<<<<<<look

  }
 
  // if there second flash // <<<<<<<<     wrong, same trigger noted
  if (trig == high && count == 1) { // <<<<   see we're checking same condition created

 //....   



Arduino Forum > Using Arduino > Programming Questions > Sketch is running on Uno, but not on ATtiny45


arduino

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code