チーム1613
課題名
飽きない1分タイマー
研究者名
Sei Shu
Aritsune Shuto
概要
ラボのtimer_pwm2を応用し、1分タイマーを作った。
1分タイマーでは、何秒かごとにドレミファソラシドの順に
音が変わるよう設定し、60秒経過した時にアラームが鳴り、
LCDに"60 second "と表示するようにした。
使用機器
・PSoC基盤 1個
・MiniProg 1個
・スピーカー 1個
ソースコード
#include <m8c.h> // part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all User Modules
#pragma interrupt_handler myISR
int SETTIME=60; //1 minutes
int PW=125; //Pulse Width
int SILENT=0, D=229/12, L=204/12, M=182/12, F=172/12, S=153/12, R=136/12, C=121/12, DD=115/12; //Scale
int TC=0; //Time Count
char tc[10];
char st[10];
void myISR(void)
{
TC += 1;//TC = TC+1 PWM16_1_WritePulseWidth(PW); itoa(tc, TC/2, 10); if(TC < SETTIME*2){ LCD_1_Position(0,0); LCD_1_PrString(tc); } if(TC >= SETTIME*2){ itoa(st, SETTIME, 10); LCD_1_Position(0,0); LCD_1_PrString(st); LCD_1_PrCString(" second "); PWM16_1_WritePeriod(DD); } else if(TC == 1) PWM16_1_WritePeriod(D); else if(TC == 8) PWM16_1_WritePeriod(L); else if(TC == 16) PWM16_1_WritePeriod(M); else if(TC == 26) PWM16_1_WritePeriod(F); else if(TC == 38) PWM16_1_WritePeriod(S); else if(TC == 52) PWM16_1_WritePeriod(R); else if(TC == 68) PWM16_1_WritePeriod(C); else if(TC == 86) PWM16_1_WritePeriod(DD); else if(TC == 118) PWM16_1_WritePeriod(SILENT);
}
void main(void)
{
// M8C_EnableGInt ; // Uncomment this line to enable Global Interrupts // Insert your main routine code here. M8C_EnableGInt; PWM16_1_Start(); LCD_1_Start(); Timer16_1_EnableInt(); Timer16_1_Start(); while(1) {};
}
配線
[#haa50c0e]
考察
音の周波数を変化させるためには、VC3のdevide値を変化させればよい。
また、音楽の音程さえ分かれば、時間幅と音程を変えてアラームが鳴るまで様々な音楽を演奏させることが
できるのではないかと考えた。
- 最終更新:2016-05-17 16:08:43