LED Light buzzer

Source: Internet
Author: User
/int main (void) {/* Configure the GPIO pin mode used by the Shenzhou III LED lamp */Rcc_apb2periphclockcmd (rcc_gpio_led, ENABLE); /* GPIO clock to enable LED lights */Gpio_initstructure.gpio_pin = ds1_pin| ds2_pin| ds3_pin| 
  	Ds4_pin;
  	Gpio_initstructure.gpio_mode = gpio_mode_out_pp;
  
  	Gpio_initstructure.gpio_speed = Gpio_speed_50mhz;  Gpio_init (gpio_led, &gpio_initstructure); /* The LED lights associated with Shenzhou III are initialized with the GPIO port */gpio_setbits (gpio_led,ds1_pin| ds2_pin| ds3_pin|
		Ds4_pin);/* Turn off all LEDs */while (1) {count=++count%4; Gpio_setbits (gpio_led,ds1_pin| ds2_pin| ds3_pin|	Ds4_pin);/* Turn off all LEDs */turn_on_led (count);
		Light an LED light Delay (0X2FFFFF); Gpio_resetbits (gpio_led,ds1_pin| ds2_pin| ds3_pin| Ds4_pin);
  	/* Light all Lights *///delay (0X2FFFFF); }}/* lights the corresponding light */void turn_on_led (U8 led_num) {switch (led_num) {case 0:gpio_resetbits (gpio_led,ds1  _pin);
        /* Light DS1 light */break; Case 1:gpio_resetbits (Gpio_leD,ds2_pin);
        /* Light DS2 light */break;  Case 2:gpio_resetbits (Gpio_led,ds3_pin);
        /* Light DS3 light */break;  Case 3:gpio_resetbits (Gpio_led,ds4_pin);          
        /* Light DS4 light */break; Default:gpio_resetbits (gpio_led,ds1_pin| ds2_pin| ds3_pin| Ds4_pin);
	/* Light all lights */break; }}///////////////////////////////////int main (void) {/* Enable buzzer to use GPIO clock */Rcc_apb2periphclockcmd (BUZZER_GPIO_CLK, E

  	nable);
  	/* GPIO pin used by the INIT buzzer */gpio_initstructure.gpio_pin = Beeper_pin;
  	Gpio_initstructure.gpio_mode = Gpio_mode_out_od;
  	Gpio_initstructure.gpio_speed = Gpio_speed_50mhz;
 
  	Gpio_init (Gpio_beeper, &gpio_initstructure);     while (1) {gpio_setbits (gpio_beeper, Beeper_pin);  
		/* Turn off the buzzer */Delay (0X2FFFFF);	Gpio_resetbits (Gpio_beeper, Beeper_pin);

  	/* Turn on Buzzer */Delay (0X2FFFFF);
 }
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.