Example #1
0
void INThandler(int sig)
{
     signal(sig, SIG_IGN);
     usleep(50000);
     softToneWrite(GPIO_TONE, 0);
     usleep(50000);
     softToneWrite(GPIO_TONE, 0);
     exit(0);
}
Example #2
0
File: b1.c Project: ifbyair/buzzer
int main(int ac, char *av[]){
    volatile int i,f;
    wiringPiSetup();

    f = softToneCreate(BUZZ_PIN);
    printf("We got %d",f);

    for(i=0; i<10; i++){
        softToneWrite(BUZZ_PIN,150); 
        delay(5);
        softToneWrite(BUZZ_PIN,0); 
        delay(100);
    }
}
int main ()
{
  int i ;

  wiringPiSetup () ;

  softToneCreate (PIN) ;

  softToneWrite (PIN, scale [0]) ;
  delay (50) ;
}
Example #4
0
int main ()
{
  int i ;
  wiringPiSetup () ;
  softToneCreate (PIN) ;
  for (i = 0 ; i < 23 ; ++i)
    {
      printf ("%3d\n", i) ;
      softToneWrite (PIN, scale [i]) ;
      delay (200) ;
    }
}
Example #5
0
int main() {
    wiringPiSetupGpio();
    softToneCreate(GPIO_TONE);
    signal(SIGINT, INThandler);

    while(1) {
        for(int tone=500; tone<=2000; tone+=10 ) {
            printf("You are listening to %dhz\n", tone);
            softToneWrite(GPIO_TONE, tone);
            usleep(5000);
        }
        for(int tone=2000; tone>500; tone-=10 ) {
            printf("You are listening to %dhz\n", tone);
            softToneWrite(GPIO_TONE, tone);
            usleep(5000);
        }
    }

    softToneWrite(GPIO_TONE, 0);
    return 0;
}
int musicPlay()
{
   int i ;

   softToneCreate(SPKR) ;                     /* 톤 출력을 위한 GPIO 설정 */

   for (i = 0; i < TOTAL; ++i) {
      softToneWrite(SPKR, notes[i]);        /* 톤 출력 : 학교종 연주 */
      delay(280);                                       /* 음의 전체 길이만큼 출력되도록 대기 */
   }

   return 0;
}
Example #7
0
void tone (int freq) {
	softToneWrite (BUZ_PORT, freq);
}
Example #8
0
void playMusic()
{

    int a;

    int i;

    for (int i = 0; i<devices; i++)
    {
        if (is_buzzer[i])
        {
            softToneCreate(pins[i][0]);
        }
        else
        {
            digitalWrite(pins[i][0], 1);
            digitalWrite(pins[i][1], HIGH);
            digitalWrite(pins[i][1], LOW);
        }

    }

    i=-1;

    while (1)
    {
        for (i = 0; i<devices; i++)
        {
            if (is_buzzer[i])
            {

                if (millis() >= endTime[i])
                {

                    a = note_number[i];

                    getMusic(i, a);

                    if (song[0] == -2) {
                        return;
                    }

                    softToneWrite (pins[i][0], 0);
                    note_number[i] = note_number[i]+1;

                    softToneWrite (pins[i][0], (freq[(song[1]+3+changes[i])*12 + song[0]]));

                    endTime[i] = millis() + song[2];
                }

            }
           else
           {
                if (millis() >= endTime[i])
                {
                    note_number[i] = note_number[i]+1;
                    a = note_number[i];

                    getMusic(i, a);

                    if (song[0] == -2) {
                        return;
                    }
                    else if (song[0] != -1)
                    {
                        pause_a[i] = (floppyConv /(freq[(song[1]+3+changes[i])*12 + song[0]]))/100;

                        pauseTime[i] = micros() + pause_a[i];
                    }
                    else
                    {
                        pauseTime[i] = INT_MAX;
                    }

                    endTime[i] = millis() + song[2];

                }

                if (micros() >= pauseTime[i])
                {

                    if (dir[i] == 0)
                        dir[i] = 1;
                    else
                        dir[i] = 0;

                    digitalWrite(pins[i][0], dir[i]);
                    pauseTime[i] = micros() + pause_a[i];
                    digitalWrite(pins[i][1], HIGH);
                    digitalWrite(pins[i][1], LOW);
                }
           }
        }

    }

}
Example #9
0
void  Beep_Tone(int pin_number, int freq)
{
	for(;;)
		softToneWrite(pin_number, freq);
}