int main(void) { unsigned constrained = 0, shutOffBuzzer = 0; //Set GPIO Pins if(!shutOffBuzzer) DDRB|=0b00100000; //PIN 13 output to buzzer DDRB|=0b00001000; sei(); setupADC(); setupPWM(); startPWM(); count=0; InitTimer0(); StartTimer0(); while(1) { if(state) pwm_val = remap(adc_val,100,900); else { //0-255 steps for tone strength constrained = remap(adc_val,619,890); //Output tone tone(constrained); } } }
int main(void) { InitPort(); InitTimer0(); StartTimer0(); while(1) { //doing nothing } }
// Start program int main(void) { // Timer initialize InitTimer1(); InitTimer0(); // Set LED pin to output LED_DDR = (1 << LED_OUT); // Enable interrupts sei(); while(1) { // Sleep Mode set_sleep_mode(SLEEP_MODE_IDLE); sleep_mode(); // If command exists ... compare if (CmdDone == 1) { // If matches required command if (RC5_cmd_val == RC5_CMD) { // Sleep disablen //sleep_disable(); // Set output to 1 LED_PORT |= (1 << LED_OUT); // Set CmdMatch to 1 ... no new command will be sampled CmdMatch = 1; // Set TimerValue to zero TimerValue = 0; // Start counting StartTimer0(); } // Reset all values RC5_cmd_val = 0x00; CmdBitNumber = 7; StartBit = 0; CmdDone = 0; } } }