controlling multi led

Hello.
By using the code below we can control one led by voice commands.

how can I edit this code in order to control multi led like 3 or 4 for example


/**


  • @file vr_sample_control_led.ino
  • @author JiapengLi
  • @brief This file provides a demostration on
    how to control led by using VoiceRecognitionModule

  • @note:
    voice control led

2013/06/13 Initial version.
*/

#include <SoftwareSerial.h>
#include “VoiceRecognitionV3.h”

/**
Connection
Arduino VoiceRecognitionModule
2 -------> TX
3 -------> RX
*/
VR myVR(2,3); // 2:RX 3:TX, you can choose your favourite pins.

uint8_t records[7]; // save record
uint8_t buf[64];

int led = 13;

#define onRecord (0)
#define offRecord (1)

/**
@brief Print signature, if the character is invisible,
print hexible value instead.
@param buf → command length
len → number of parameters
/
void printSignature(uint8_t buf, int len)
{
int i;
for(i=0; i<len; i++){
if(buf_>0x19 && buf
<0x7F){
_
_ Serial.write(buf*);
}
else{
Serial.print("[");
Serial.print(buf, HEX);
Serial.print("]");
}
}
}
/**
@brief Print signature, if the character is invisible,
print hexible value instead.
@param buf → VR module return value when voice is recognized.
buf[0] → Group mode(FF: None Group, 0x8n: User, 0x0n:System*

* buf[1] → number of record which is recognized.
buf[2] → Recognizer index(position) value of the recognized record.
buf[3] → Signature length*

* buf[4]~buf[n] → Signature*
/
void printVR(uint8_t *buf)
{
Serial.println(“VR Index\tGroup\tRecordNum\tSignature”);
Serial.print(buf[2], DEC);
Serial.print("\t\t");
if(buf[0] == 0xFF){
Serial.print(“NONE”);
}
else if(buf[0]&0x80){
Serial.print(“UG “);
Serial.print(buf[0]&(~0x80), DEC);
}
else{
Serial.print(“SG “);
Serial.print(buf[0], DEC);
}
Serial.print(”\t”);
Serial.print(buf[1], DEC);
Serial.print(”\t\t”);
if(buf[3]>0){
printSignature(buf+4, buf[3]);
}
else{
Serial.print(“NONE”);
}
Serial.println("\r\n");
}
void setup()
{
/** initialize /
myVR.begin(9600);
_

* Serial.begin(115200);*
* Serial.println(“Elechouse Voice Recognition V3 Module\r\nControl LED sample”);*

* pinMode(led, OUTPUT);*

* if(myVR.clear() == 0){*
* Serial.println(“Recognizer cleared.”);*
* }else{*
* Serial.println(“Not find VoiceRecognitionModule.”);*
* Serial.println(“Please check connection and restart Arduino.”);*
* while(1);*
* }*

* if(myVR.load((uint8_t)onRecord) >= 0){
_ Serial.println(“onRecord loaded”);
}*_

* if(myVR.load((uint8_t)offRecord) >= 0){
_ Serial.println(“offRecord loaded”);
}
}
void loop()
{
int ret;
ret = myVR.recognize(buf, 50);
if(ret>0){
switch(buf[1]){
case onRecord:
/** turn on LED /
digitalWrite(led, HIGH);

* break;
case offRecord:
/** turn off LED/

* digitalWrite(led, LOW);
break;
default:
Serial.println(“Record function undefined”);
break;
}
/** voice recognized /
printVR(buf);

* }
}
*_</em></em> <em><em><em>**</em></em></em> <em><em>_**_

Sounds to me that you are simply blindly copying and pasting code without understanding what it does.

Now you want someone else to figure the code out for you and make the changes?

You had better learn how to program.

Why does the code turn italic in the middle?

Is this homework?

If you need help, post where you bought the voice module and its documentation.

yes I have a project.

I did that and this code is from it's documentation.

But I want to edit it to control multi led because this code for one led.

Ali_Ismail:
yes I have a project.

I did that and this code is from it's documentation.

But I want to edit it to control multi led because this code for one led.

As I wrote before, learn to program.

I understood it and I had an idea how to edit it,but Iam asking the doctors and mavens in arduino because this was the first step for me in programming arduino and to collect more informations to confirm this code.

Thanks for your attention

Ali_Ismail:
I understood it and I had an idea how to edit it,but Iam asking the doctors and mavens in arduino because this was the first step for me in programming arduino and to collect more informations to confirm this code.

Thanks for your attention

Post your sketch.

You are caught in a hard place, as a project, members are always willing to help, but not do the work for you...

However, if the code you posted is a published 'example', you have greater problems. That code sample is an abomination, and hardly worthy of reworking... it needs to be rewritten from scratch!

See if you can contact the author, they may have other better examples to start from. If not, look for a local experienced hacker that can work with you to understand the device and function calls - then develop your solution.

I suspect what you're looking for is doable, but not enough info yet.

Perhaps we all missed the basic question...

how can I edit this code in order to control multi led like 3 or 4 for example

Basic answer:
Add more statements like the following for 2 or 3 more "x" pins...
pinMode(x, OUTPUT);

THen turn them on and off with more of these lines...

digitalWrite(x, HIGH);

digitalWrite(x, LOW);

Under what conditions you want to turn them on and off is up to you.