/* * piano.c * Programa para hacer un piano en C con microcontrolador atmega8535 * Created: 18/10/2012 11:22:15 a.m. * Author: Rodrigo Salvador */ #define F_CPU 1000000UL #include
#include #include #include #include "notes_freq.h" int configurarCTC(); int8_t notamusC; int8_t notamusA; int8_t anteriorA; int8_t anteriorC; int main(void) { configurarCTC (); DDRA DDRA = 0x0 0x00; 0; DDRC DDRC = 0x0 0x00; 0; //PU //PUER ERTO TOS S A Y C COMO COMO ENTR ENTRAD ADA A while(1); { notamusA=PINA; notamusC=PINC; //LEER LOS PUERTOS A Y C if (notamusA == anteriorA) //COMPARAR LA NUEVA LECTURA DEL PUERT OA CON LA ANTERIOR { return 0; //SI ES IGUAL REGRESA AL INICIO, ENTONCES GENE RA LA MISMA FRECUENCIA } else if (notamusC == anteriorC) //COMPARAR LA NUEVA LECTURA DEL PUERTOC CON LA ANTERIOR { return 0; //SI ES IGUAL A LA ANTERIORC REGRESA AL INICIO , GENERA LA MISMA FRECUENCIA } else { DDRB = (1<
OCR0=0x00;
break; case F_1: break; case G1: break; default: switch (notamusA) { case G_1: OCR0=0x00; case A1: OCR0=0x00; case A_1: OCR0=0x00; case B1: OCR0=0x00; case C2: OCR0=0x00; case C_2: OCR0=0x00; case D2: OCR0=0x00; case D_2: OCR0=0x00; default:
OCR0=0x00; OCR0=0x00;
24; 22; 20; 1E; 1C; 1B; 19; 18; break;
TCNT0=0x29; TCNT0=0x26;
TCNT0=0x break; break; break; break; break; break; break; break;
}
}
} }
break;
} configurarCTC() { TCCR0|=(1<
TCNT0=0x TCNT0=0x TCNT0=0x TCNT0=0x TCNT0=0x TCNT0=0x TCNT0=0x