Onenet read and control the LED status on the development of Kylin seat

Source: Internet
Author: User

Hardware

Unicorn Seat mini Development Board V1.4

Embedded Software

Onenet_demo_esp8266_edp_led

Project Modification Content
    1. LED.C File Modification

      • Function Led_init,mini Development Board LEDs are located in Gpio PB6, PB7, PB8, PB9

      • Function Led_getvalue,mini Development Board LED status opposite IO port status

/**
* @brief LED Indicator initialization function
**/
voidLed_init (void
{
Gpio_inittypedefGpio_initstructure;
pb9--corresponding Development Board red indicator; pb8--corresponding Development Board green indicator;
pb7--corresponding Development Board yellow indicator; PB6---Corresponding Development Board blue indicator
Rcc_apb2periphclockcmd (RCC_APB2PERIPH_GPIOB,ENABLE);
Gpio_initstructure.Gpio_pin=Gpio_pin_6|Gpio_pin_7|Gpio_pin_8|Gpio_pin_9;
Gpio_initstructure.Gpio_speed=Gpio_speed_50mhz;
Gpio_initstructure.Gpio_mode=GPIO_MODE_OUT_PP;
Gpio_init (GPIOB,&Gpio_initstructure);
}
?
/**
* @brief Get the current status value of the LED
**/
voidLed_getvalue (void
{
IfGpio_readoutputdatabit (GPIOB,Gpio_pin_9))
{
Red_value=0;
}
Else
{
Red_value=1;
}
IfGpio_readoutputdatabit (GPIOB,Gpio_pin_6))
{
Blue_value=0;
}
Else
{
Blue_value=1;
}
IfGpio_readoutputdatabit (GPIOB,Gpio_pin_8))
{
Green_value=0;
}
Else
{
Green_value=1;
}
IfGpio_readoutputdatabit (GPIOB,gpio_pin_7))
{
yellow_value=0;
}
else
{
Span class= "Cm-tab" > yellow_value=1;
}
}
?

    1. Led.h File Modification

  #define Led_red_off       gpio_setbits (gpiob,gpio_pin_9) 
#define Led_green_off     gpio_setbits (gpiob,gpio_pin_8)
#define Led_yellow_off   Gpio_setbits (gpiob,gpio_pin_7)
#define Led_blue_off     Gpio_setbits (gpiob,gpio_pin_6)
?
#define LED_RED_ON       gpio_resetbits (gpiob,gpio_pin_9)
#define LED_GREEN_ON     gpio_resetbits (gpiob,gpio_pin_8)
#define LED_YELLOW_ON     gpio_resetbits (gpiob,gpio_pin_7)
#define LED_BLUE_ON       gpio_resetbits (gpiob,gpio_pin_6)
    1. ESP8266.h File Modification

#define DEVICEID "XXXXXX"
#define APIKEY "Xxxxxxxxxxxxxxxxxx"
#define CWJAP "at+cwjap=\" xxxxxxxx\ ", \" xxxxxxx\ "\ r \ n"

top two macros define Onenet platform-related, last WiFi SSID name and password, these three macros are modified according to their needs

onenet Platform Operation
    1. Set GPIO status

The above command realizes the bright blue led.

    1. Read GPIO status

Currently showing blue lit, other three LEDs off

Reference

1. https://github.com/cm-heclouds/OneNET_demo_code_kylin/tree/master/OneNET_Demo_ESP8266_EDP_Led

2. Https://github.com/cm-heclouds/OneNET_demo_code_kylin/blob/master/OneNET_Demo_User_Guide.pdf

Onenet read and control the LED status on the development of Kylin seat

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.