예제 #1
0
int main ()
{
  int i ;

  wiringPiSetup () ;

  softToneCreate (PIN) ;

  softToneWrite (PIN, scale [0]) ;
  delay (50) ;
}
예제 #2
0
int main ()
{
  int i ;
  wiringPiSetup () ;
  softToneCreate (PIN) ;
  for (i = 0 ; i < 23 ; ++i)
    {
      printf ("%3d\n", i) ;
      softToneWrite (PIN, scale [i]) ;
      delay (200) ;
    }
}
int musicPlay()
{
   int i ;

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

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

   return 0;
}
예제 #4
0
파일: b1.c 프로젝트: 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);
    }
}
예제 #5
0
파일: robot.c 프로젝트: saljs/robo-gen
//setup different inputs and outputs
int setup()
{
    //load the spi daemon
    system("/usr/local/bin/gpio load spi");
    if (wiringPiSetup () == -1)
    {
        return 1;
    }

    //atd converter
    mcp3004Setup (200, 0);

    //collision sensors
    pinMode (5, INPUT);

    //motors
    pinMode(7, OUTPUT);
    pinMode(4, OUTPUT);
    pinMode(2, OUTPUT);

    //ultrasonic
    pinMode(8, OUTPUT);
    pinMode(9, INPUT);

    //Power button
    pinMode (11, INPUT);

    //random seed
    struct timeval time;
    gettimeofday(&time,NULL);
    srandom((time.tv_sec * 100) + (time.tv_usec / 100));

    //pizeo setup
    pinMode(3, OUTPUT);
    softToneCreate(3);

    //status LED
    pinMode(6, OUTPUT);
    //turn the LED on. When the program exits it will turn off, indicating a dead battery
    digitalWrite(6, HIGH);

    return 0;
}
예제 #6
0
파일: piano.c 프로젝트: macole/raspberrypi
int main (void) {
	int data, i;

	//初期化
	if(wiringPiSetupGpio() == -1) return 1;
	softToneCreate (BUZ_PORT);
	pinMode(GPIO_4_DO, INPUT);
	pinMode(GPIO_4_RE, INPUT);
	pinMode(GPIO_4_MI, INPUT);
	pinMode(GPIO_4_FA, INPUT);
	pinMode(GPIO_4_SO, INPUT);
	pinMode(GPIO_4_RA, INPUT);
	pinMode(GPIO_4_SI, INPUT);
	pinMode(GPIO_5_DO, INPUT);
	pinMode(GPIO_4_DOs, INPUT);
	pinMode(GPIO_4_REs, INPUT);
	pinMode(GPIO_4_FAs, INPUT);
	pinMode(GPIO_4_SOs, INPUT);
	pinMode(GPIO_4_RAs, INPUT);

	//繰り返し
	while (1) {
		if(digitalRead(GPIO_4_DO) == 1) { tone(TONE_4_DO); }
		else if(digitalRead(GPIO_4_RE) == 1) { tone(TONE_4_RE); }
		else if(digitalRead(GPIO_4_MI) == 1) { tone(TONE_4_MI); }
		else if(digitalRead(GPIO_4_FA) == 1) { tone(TONE_4_FA); }
		else if(digitalRead(GPIO_4_SO) == 1) { tone(TONE_4_SO); }
		else if(digitalRead(GPIO_4_RA) == 1) { tone(TONE_4_RA); }
		else if(digitalRead(GPIO_4_SI) == 1) { tone(TONE_4_SI); }
		else if(digitalRead(GPIO_5_DO) == 1) { tone(TONE_5_DO); }
		else if(digitalRead(GPIO_4_DOs) == 1) { tone(TONE_4_DOs); }
		else if(digitalRead(GPIO_4_REs) == 1) { tone(TONE_4_REs); }
		else if(digitalRead(GPIO_4_FAs) == 1) { tone(TONE_4_FAs); }
		else if(digitalRead(GPIO_4_SOs) == 1) { tone(TONE_4_SOs); }
		else if(digitalRead(GPIO_4_RAs) == 1) { tone(TONE_4_RAs); }
		else { tone(0); }
		delay(WAIT_MS);
	}

	return 0;
}
예제 #7
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;
}
예제 #8
0
파일: RPi.c 프로젝트: jereksel/MidiToFloppy
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);
                }
           }
        }

    }

}
예제 #9
0
파일: main.c 프로젝트: pablo-new17/BananaPi
void init_beep(int pin_number)
{
	softToneCreate(pin_number);
}