int main(void) { //set outputs DDRB=0xff; //all out for now PORTB=0b000; //all output low //make sure heater is OFF and the slot is not held down heater(0); //set inputs DDRA=0x00; //all in PORTA=0b011; //no pull-up for the trimmer //setup interupt for counting time TCCR1A=(1<<WGM12); //clear counter on compare match TCCR1B=(1<<CS11)|(1<CS10); //1MHZ/64=15.625kHz OCR1A=15625; //compare match at 1Hz TIMSK1=(1<<OCIE1A); //interupt on compare match a //setup adc for trimmer ADMUX=(1<<MUX1); //set PA2 for adc ADCSRB=(1<<ADLAR); //set for reading of highest bits ADCSRA=(1<<ADEN)|(1<<ADSC)|(1<<ADATE); //start free run mode //setup SPI slave DDRA|=(1<<5); USICR = (1<<USIWM0)|(1<<USICS1)|(1<<USIOIE); USISR = (1<<USICNT0); sei();//enable interrupt //end of setup while(1) //be stuck forever. { if(!slot()) //hold the toast down { time=trimmer(); //set timer according to knob heater(1); debug(1); hold(1); while(button()); //wait for user input heater(0); hold(0); debug(0); while(!button()); //wait untill button is released } } }
int main() { Heater heater(10); heater.checkMax(); heater.setTemp(90); heater.checkMax(); heater.setTemp(110); heater.checkMax(); return 1; }