I've not got much idea about writing in C, but I'll try to explain what i want/need.

I've found a program to switch 4 sectors of a eprom using a18 a19 on the eprom, and switched by an atiny85
I've programmed the eprom and the attiny and that side of it works fine
I want to add a piezzo buzzer to one on the spare legs.

When the reset on the pc is held for less than two seconds it resets, to last one booted,
but if its held longer
2 seconds bank 1
3 seconds bank 2
4 seconds bank 3
5 seconds bank 4

Its a bit of a lottery counting in my head, so i'd like to add a buzzer to count from 2 - 5 seconds, basically buzz on 2 ,3 ,4 ,5 so I know when to let go to boot which sector.

This is the program that works, i have pins 2 and 3 free as it stands to add a buzzer.

#define F_CPU 8000000UL
// PB0 for KBRESET
#define AMIGARESETPIN 0


#define CHECKRESETDELAYMS 250


#define FIRSTWAITTHRESHOLDMS 2000
#define SECONDWAITTHRESHOLDMS 3000
#define THIRDWAITTHRESHOLDMS 4000
#define FOURTHWAITTHRESHOLDMS 5000


#define MASTERWAITTHRESHOLDMS 10000


#include <avr/io.h>
#include <avr/eeprom.h>
#include <util/delay.h>


/*
PB0 - KBRESET on Amiga
PB1 - A18 on 27C160
PB2 - A19 on 27C160


Logic is;


PB1, PB2 default to one of the four kickstarts on the 27C160
when PB0 is held low for FIRSTWAITTHRESHOLDMS then PB1=0, PB2=0
when PB1 is held low for SECONDWAITTHRESHOLDMS then PB1=1, PB2=0
when PB1 is held low for THIRDWAITTHRESHOLDMS then PB1=0, PB2=1
when PB1 is held low for FOURTHWAITTHRESHOLDMS then PB1=1, PB2=1

when PB0 is held low for less than FIRSTWAITTHRESHOLDMS then the PB1/PB2
settings remain what they were last time PB0 went low

if PB0 is held low for more than MASTERWAITTHRESHOLDMS then PB1=0, PB2=0.
This is meant to be the 'I am unable to count 1001, 1002 etc in my head,
and pleas can you just reset it back to the first image'
*/
int
main (void)
{
uint8_t count;
uint8_t new_kickstart;


// PORTB outputs on PB2, PB1 and input on PB0
DDRB = 0b00000110;

new_kickstart = eeprom_read_byte((uint8_t*)0);


PORTB = (new_kickstart & 0x03) <<1;
while(1)
{
if ((PINB & (1<<AMIGARESETPIN)) == 0 ) {
count=0;
while ((PINB & (1<<AMIGARESETPIN)) == 0 ) {
count++;
switch(count) {
case (FIRSTWAITTHRESHOLDMS/CHECKRESETDELAYMS) :
new_kickstart = 0x00;
break; /* optional */
case (SECONDWAITTHRESHOLDMS/CHECKRESETDELAYMS) :
new_kickstart = 0x01;
break; /* optional */
case (THIRDWAITTHRESHOLDMS/CHECKRESETDELAYMS) :
new_kickstart = 0x02;
break; /* optional */
case (FOURTHWAITTHRESHOLDMS/CHECKRESETDELAYMS) :
new_kickstart = 0x03;
break; /* optional */

//default : /* Optional */
//PORTB = 0x00 <<1;
}
if (count>(MASTERWAITTHRESHOLDMS/CHECKRESETDELAYMS)) {
new_kickstart = 0x00;
}
PORTB = (new_kickstart & 0x03) <<1;
_delay_ms(CHECKRESETDELAYMS);


}
// only after reset goes high do we write back t eeprom
eeprom_write_byte((uint8_t*)0, new_kickstart);


}
_delay_ms(50);
}
}

I have little idea what code to add to make it work.

any help appreciated.

Ted