Introduction to Arduino Learning to implement voice control LED lights

Source: Internet
Author: User

The required hardware arduino+pc+ microphone enables voice commands to control the light off of the LED lights.

The first thing you need to do is to burn the well-written Arduino program to the Arduino UNO motherboard, the following code:

int val;//Define the variable Valint ledpin=10;//define the Digital Interface 13void Setup () {serial.begin (9600);//Set the baud rate to 9600, here to match the software settings. When accessing a specific device (e.g. Bluetooth), we also have to match the baud rate of other devices. Pinmode (ledpin,output);//Set the Number 10 port as the output interface, the Arduino on the I/O port we use to do similar to the definition. }void Loop () {val=serial.read ();//reads the instruction or character sent by the PC to the Arduino and assigned the instruction or Word to Valif (val== ' O ')//To determine whether the received instruction or character is "R". {//If you receive the "R" character digitalwrite (Ledpin,high);//Light the digital 10-Port LED. Delay (500); Serial.println ("Open Led");//display "open led! "String}if (val== ' C ') {digitalwrite (Ledpin,low);//Off Digital 10-Port LED delay (500); Serial.println ("Close Led");//display "Open led! "String}if (val== ' S ') {digitalwrite (Ledpin,high);//Light up the digital 10-Port LED. Delay (1000); Digitalwrite (Ledpin,low);//Off Digital 10-Port LED delay (1000); Serial.println ("s Led");//display "s led! "String}}

The above MCU accepts the main character o for open opening meaning, C for close off, s for led flashing. After the program is burned to the motherboard, the following we can communicate through the serial port can make the computer and the microcontroller to communicate.

Serial communication Code is as follows:

   SerialPort _serialport;         void Init ()        {            new  SerialPort ();             " COM3 " ;             9600 ;            _serialport.open ();                 }

Speech Recognition Module Online A lot of people can search here I use the Win7 comes with the main use of speech recognition

Private Speechlib.ispeechrecogrammar ISRG;
Private Speechlib.spsharedrecocontextclass Ssrcontex = null;

The overall idea is: the voice to recognize the text, and then according to their favorite words as an order, through the serial port will command sent to the single-chip microcomputer, single-chip computer wiring is also reflected in the picture, if you want to control the home of the light, you also need to relay voltage and current conversion.

Introduction to Arduino Learning to implement voice control LED lights

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.