plzzz help me out do this for me i will be greatful to you.....fix error below

/*
* MP_Final.c

*/ 

#include <avr/io.h>
#include <util/delay.h>
#include "lcd.h"

/* PIN-OUTS */
#define S0 0
#define S1 1
#define S2 6
#define S3 7
#define out 2

/* MACRO FUNC */
#define buzz() {\
DDRB |= (1<<4); PORTB |= (1<<4);\
_delay_ms(250);\
PORTB &= (~(1<<4));\
}

/* DECLARE FUNCTIONS */
void detectColor();
uint16_t pulseIn();
uint16_t colorRead(int color);
void taosMode(int mode);
void TCS3200setup();


//static uint16_t R, B, G;

int main(void)
{
/* PORTS */
DDRB |= (1<<3)|(1<<5);
DDRD = 0x0F;

/* SENSOR INITIALIZATION */
TCS3200setup();

/* LCD */
InitLCD(0);
//LCD(0,0,"ON");

/* VARIABLES */
int count = 0, i =0, old = 0, new = 0, flag = 1;
uint8_t a = PIND & 0xE0;

/* CALIBERATION SEQUENCE */
/*
uint16_t W = colorRead(0);
uint16_t R = colorRead(1);
uint16_t B = colorRead(2);
uint16_t G = colorRead(3);
*/

/* MOTOR INITIALIZATION */
TCCR0 = (1<<WGM01)|(1<<WGM00)|(1<<COM01)|(1<<CS01)|(1<<CS00); //Play with COM00; prescalar = 64

  while(1)
  {
flag = 1;
buzz();

old = new;

uint16_t white = colorRead(0);
uint16_t red   = colorRead(1);
uint16_t blue  = colorRead(2);
uint16_t green = colorRead(3);

LCDvar(0,0,red,3);
LCDvar(5,0,blue,3);
LCDvar(9,0,green,3);
LCDvar(13,0,white,3);

/*
r 1
g 2
b 3
*/

/*
if((red>=48)&&(red<=60)&&(blue>=50)&&(blue<=60)&&(green>=30)&&(green<=40)&&(white>=135)&&(white<=182))
{
LCD(0,1,"__NIL_");
flag = 0;
}
else if((red>=45)&&(red<=65)&&(blue<=40)&&(green<=33)) //red
{
//LCDClear();
LCD(0,1,"RED___");
new = 1;
} 
else if((red<=54)&&(blue>=41)&&(green<=33)) //blue
{
//LCDClear();
LCD(0,1,"_BLUE_");
new = 3;
} 
else if(green>=33) //(red>=65)&&(red<=74)&&(blue<=45)&&(blue>=38)) //yellow
{
//LCDClear();
LCD(0,1,"GREEN");
new = 2;
}
*/

if((white>=114)&&(blue>=43)&&(red>=54))
{
LCD(0,1,"__NIL_");
flag = 0;
}
else if(red>=43) //red
{
LCD(0,1,"RED___");
new = 1;
} 
else if(blue>=41) //blue
{
LCD(0,1,"_BLUE_");
new = 3;
} 
else if(green>=33) //(red>=65)&&(red<=74)&&(blue<=45)&&(blue>=38)) //yellow
{
LCD(0,1,"GREEN");
new = 2;
} 

for (i = 0; i<=2; i++)
{
_delay_ms(6000); 
}

/* CD_ROM motor */

if (old-new >= 0)
{
count = old - new;
} 
else
{
count = new - old;
}

while(count >= 1)
{
if(old-new > 0)
{ 
TCCR0 |= (1<<COM00);
PORTB &= (~(1<<5));
OCR0 = 125;

if((a==192)||(a==160))
{
--count;
}
else if(a == 96)
{
--count;
}
else
{}


_delay_ms(750);

OCR0 = 255;
PORTB &= (~(1<<5)); 
}
else if(new-old > 0)
{
TCCR0 &= (~(1<<COM00));
PORTB |= (1<<5);
OCR0 = 125;

if((a==192)||(a==160))
{
--count;
}
else if(a == 96)
{
--count;
}
else
{}

_delay_ms(750);

OCR0 = 0;
PORTB &= (~(1<<5)); 

}
else
{
DDRB &= (~(1<<3))|(~(1<<5));
TCCR0 &= (~(1<<CS01))|(~(1<<CS00));
}
} 

count = 0;

/* FLAP */

if (flag == 1)
{
PORTD = 0x01;
for (i = 0; i<=3; i++)
{
_delay_ms(1500); 
}
PORTD = 0x02;
for (i = 0; i<=2; i++)
{
_delay_ms(2000); 
}
PORTD = 0x00;
}

/* SAMPLING DELAY */

for (i = 0; i<=2; i++)
{
_delay_ms(6000); 
}

  }
}

/* FUNCTION DEFINITIONS */

/* Pulse reading from sensor variable */
uint16_t readPulse;

/*
This section will return the pulseIn reading of the selected color.  
It will turn on the sensor at the start taosMode(1),
and it will power off the sensor at the end taosMode(0)

color codes: 0=white, 1=red, 2=blue, 3=green

if LEDstate is 0, LED will be off. 1 and the LED will be on.
taosOutPin is the ouput pin of the TCS3200.
*/

uint16_t pulseIn()
{
 //If the function is entered when the level on OUT line was low
 //Then wait for it to become high.
 if(!(PINB & (1<<out)))
 {
    while(!(PINB & (1<<out)));   //Wait for rising edge  
 }


 while(PINB & (1<<out));   //Wait for falling edge

 TCNT1=0x0000;//Reset Counter

 TCCR1B=(1<<CS10); //Prescaller = F_CPU/1 (Start Counting)

 while(!(PINB & (1<<out)));   //Wait for rising edge

 //Stop Timer
 TCCR1B=0x00;

 return (8000/TCNT1);

}

uint16_t colorRead(int color){ 

//turn on sensor and use highest frequency/sensitivity setting
taosMode(1);

//setting for a delay to let the sensor sit for a moment before taking a reading.

//set the S2 and S3 pins to select the color to be sensed 
if(color == 0){//white
clr(PORTB,S3); //S3
set(PORTB,S2); //S2
// Serial.print(" w");
}

else if(color == 1){//red
clr(PORTB,S3); //S3
clr(PORTB,S2); //S2
// Serial.print(" r");
}

else if(color == 2){//blue
set(PORTB,S3); //S3
clr(PORTB,S2); //S2 
// Serial.print(" b");
}

else if(color == 3){//green
set(PORTB,S3); //S3
set(PORTB,S2); //S2 
// Serial.print(" g");
}

// wait a bit for LEDs to actually turn on, as directed by sensorDelay var
_delay_ms(100);

// now take a measurement from the sensor, timing a low pulse on the sensor's "out" pin
readPulse = pulseIn();

//if the pulseIn times out, it returns 0 and that throws off numbers. just cap it at 80k if it happens
if(readPulse < 10){
readPulse = 16000;
}

//turn off color sensor and LEDs to save power 
taosMode(0);

// return the pulse value back to whatever called for it... 
return readPulse;

}

/*Operation modes controlled by S0 and S1 pins. setting mode to zero = low power mode.*/

void taosMode(int mode){
  
  if(mode == 0){
  //power OFF mode-  LED off and both channels "low"
  clr(PORTB,S0); //S0
  clr(PORTB,S1); //S1
  //  Serial.println("mOFFm");
  
  }else if(mode == 1){
  //this will put in 1:1, highest sensitivity
  set(PORTB,S0); //S0
  set(PORTB,S1); //S1
  // Serial.println("m1:1m");
  
  }else if(mode == 2){
  //this will put in 1:5
  set(PORTB,S0); //S0
  clr(PORTB,S1); //S1
  //Serial.println("m1:5m");
  
  }else if(mode == 3){
  //this will put in 1:50
  clr(PORTB,S0); //S0
  set(PORTB,S1); //S1 
  //Serial.println("m1:50m");
  }    
}

void TCS3200setup(){
  
  //color mode selection
  set(DDRB,S2); //S2 pinE
  set(DDRB,S3); //s3 pinF
  
  //color response pin (only actual input from taos)
  clr(DDRB,out); //taosOutPin pinC
  
  //communication freq (sensitivity) selection
  set(DDRB,S0); //S0 pinB
  set(DDRB,S1); //S1 pinA 

}

................error after compiling
ketch_mar15a.ino: In function 'int main()':
sketch_mar15a:46: error: 'InitLCD' was not declared in this scope
sketch_mar15a:50: error: expected unqualified-id before 'new'
sketch_mar15a:62: error: 'TCCR0' was not declared in this scope
sketch_mar15a:62: error: 'COM01' was not declared in this scope
sketch_mar15a:66: error: 'flag' was not declared in this scope
sketch_mar15a:69: error: expected type-specifier before ';' token
sketch_mar15a:76: error: 'LCDvar' was not declared in this scope
sketch_mar15a:115: error: 'LCD' was not declared in this scope
sketch_mar15a:120: error: 'LCD' was not declared in this scope
sketch_mar15a:121: error: expected type-specifier before '=' token
sketch_mar15a:125: error: 'LCD' was not declared in this scope

And your point is?

Does "lcd.h" reside in the same folder as your sketch?

Also, you have posted code without using code tags. This creates certain problems and obstacles for other forum members. The code tags make the code look

like this

when posting source code files. It makes it easier to read, and can be copied with a single mouse click.
If you have already posted without using code tags, open your message and select "modify" from the pull down menu labelled, "More", at the lower left corner of the message. Highlight your code by selecting it (it turns blue), and then click on the "</>" icon at the upper left hand corner. Click on the "Save" button. Code tags can also be inserted manually in the forum text using the [code] and [/code] metatags.

When you are finished that, please read these two posts:

How to use this forum - please read.
and
Read this before posting a programming question ...

sorry sir help me out

I expect an Arduino program to have a setup() function and a loop() function, not a main function that takes no arguments. It could happen but it is unlikely, especially by someone who doesn't use code tags.

The date is currently March 2016. Why am I seeing code posted that claims to have been created by W in November 2014, nearly 16 months ago?

mahi12:
i want to fix that errors

If you don't pay any attention to replies, I don't see how that will ever happen.

/*
 * MP_Final.c
 *
 * Created: 20-11-2014 01:41:49
 *  Author: W
 */ 

#include <avr/io.h>
#include <util/delay.h>
#include "lcd.h"

/* PIN-OUTS */
#define S0 0
#define S1 1
#define S2 6
#define S3 7
#define out 2

/* MACRO FUNC */
#define buzz() {\
DDRB |= (1<<4); PORTB |= (1<<4);\
_delay_ms(250);\
PORTB &= (~(1<<4));\
}

/* DECLARE FUNCTIONS */
void detectColor();
uint16_t pulseIn();
uint16_t colorRead(int color);
void taosMode(int mode);
void TCS3200setup();


//static uint16_t R, B, G;

int main(void)
{
 /* PORTS */
 DDRB |= (1<<3)|(1<<5);
 DDRD = 0x0F;
 
 /* SENSOR INITIALIZATION */
 TCS3200setup();
 
 /* LCD */
 InitLCD(0);
 //LCD(0,0,"ON");
 
 /* VARIABLES */
 int count = 0, i =0, old = 0, new = 0, flag = 1;
 uint8_t a = PIND & 0xE0;
 
 /* CALIBERATION SEQUENCE */
 /*
 uint16_t W = colorRead(0);
 uint16_t R = colorRead(1);
 uint16_t B = colorRead(2);
 uint16_t G = colorRead(3);
 */
 
 /* MOTOR INITIALIZATION */
 TCCR0 = (1<<WGM01)|(1<<WGM00)|(1<<COM01)|(1<<CS01)|(1<<CS00); //Play with COM00; prescalar = 64
 
    while(1)
    {
 flag = 1;
 buzz();
 
 old = new;
 
 uint16_t white = colorRead(0);
 uint16_t red   = colorRead(1);
 uint16_t blue  = colorRead(2);
 uint16_t green = colorRead(3);
 
 LCDvar(0,0,red,3);
 LCDvar(5,0,blue,3);
 LCDvar(9,0,green,3);
 LCDvar(13,0,white,3);
 
 /*
 r 1
 g 2
 b 3
 */
 
 /*
 if((red>=48)&&(red<=60)&&(blue>=50)&&(blue<=60)&&(green>=30)&&(green<=40)&&(white>=135)&&(white<=182))
 {
 LCD(0,1,"__NIL_");
 flag = 0;
 }
 else if((red>=45)&&(red<=65)&&(blue<=40)&&(green<=33)) //red
 {
 //LCDClear();
 LCD(0,1,"RED___");
 new = 1;
 } 
 else if((red<=54)&&(blue>=41)&&(green<=33)) //blue
 {
 //LCDClear();
 LCD(0,1,"_BLUE_");
 new = 3;
 } 
 else if(green>=33) //(red>=65)&&(red<=74)&&(blue<=45)&&(blue>=38)) //yellow
 {
 //LCDClear();
 LCD(0,1,"GREEN");
 new = 2;
 }
 */
 
 if((white>=114)&&(blue>=43)&&(red>=54))
 {
 LCD(0,1,"__NIL_");
 flag = 0;
 }
 else if(red>=43) //red
 {
 LCD(0,1,"RED___");
 new = 1;
 } 
 else if(blue>=41) //blue
 {
 LCD(0,1,"_BLUE_");
 new = 3;
 } 
 else if(green>=33) //(red>=65)&&(red<=74)&&(blue<=45)&&(blue>=38)) //yellow
 {
 LCD(0,1,"GREEN");
 new = 2;
 } 
 
 for (i = 0; i<=2; i++)
 {
 _delay_ms(6000); 
 }
 
 /* CD_ROM motor */
 
 if (old-new >= 0)
 {
 count = old - new;
 } 
 else
 {
 count = new - old;
 }
 
 while(count >= 1)
 {
 if(old-new > 0)
 { 
 TCCR0 |= (1<<COM00);
 PORTB &= (~(1<<5));
 OCR0 = 125;
 
 if((a==192)||(a==160))
 {
 --count;
 }
 else if(a == 96)
 {
 --count;
 }
 else
 {}
 
 
 _delay_ms(750);
 
 OCR0 = 255;
 PORTB &= (~(1<<5)); 
 }
 else if(new-old > 0)
 {
 TCCR0 &= (~(1<<COM00));
 PORTB |= (1<<5);
 OCR0 = 125;
 
 if((a==192)||(a==160))
 {
 --count;
 }
 else if(a == 96)
 {
 --count;
 }
 else
 {}
 
 _delay_ms(750);
 
 OCR0 = 0;
 PORTB &= (~(1<<5)); 
 
 }
 else
 {
 DDRB &= (~(1<<3))|(~(1<<5));
 TCCR0 &= (~(1<<CS01))|(~(1<<CS00));
 }
 } 
 
 count = 0;
 
 /* FLAP */
 
 if (flag == 1)
 {
 PORTD = 0x01;
 for (i = 0; i<=3; i++)
 {
 _delay_ms(1500); 
 }
 PORTD = 0x02;
 for (i = 0; i<=2; i++)
 {
 _delay_ms(2000); 
 }
 PORTD = 0x00;
 }
 
 /* SAMPLING DELAY */
 
 for (i = 0; i<=2; i++)
 {
 _delay_ms(6000); 
 }
 
    }
}

/* FUNCTION DEFINITIONS */

/* Pulse reading from sensor variable */
uint16_t readPulse;

/*
This section will return the pulseIn reading of the selected color.  
It will turn on the sensor at the start taosMode(1),
and it will power off the sensor at the end taosMode(0)

color codes: 0=white, 1=red, 2=blue, 3=green

if LEDstate is 0, LED will be off. 1 and the LED will be on.
taosOutPin is the ouput pin of the TCS3200.
*/

uint16_t pulseIn()
{
   //If the function is entered when the level on OUT line was low
   //Then wait for it to become high.
   if(!(PINB & (1<<out)))
   {
      while(!(PINB & (1<<out)));   //Wait for rising edge  
   }


   while(PINB & (1<<out));   //Wait for falling edge

   TCNT1=0x0000;//Reset Counter

   TCCR1B=(1<<CS10); //Prescaller = F_CPU/1 (Start Counting)

   while(!(PINB & (1<<out)));   //Wait for rising edge

   //Stop Timer
   TCCR1B=0x00;

   return (8000/TCNT1);

}

uint16_t colorRead(int color){ 
  
//turn on sensor and use highest frequency/sensitivity setting
taosMode(1);

//setting for a delay to let the sensor sit for a moment before taking a reading.

//set the S2 and S3 pins to select the color to be sensed 
if(color == 0){//white
clr(PORTB,S3); //S3
set(PORTB,S2); //S2
// Serial.print(" w");
}

else if(color == 1){//red
clr(PORTB,S3); //S3
clr(PORTB,S2); //S2
// Serial.print(" r");
}

else if(color == 2){//blue
set(PORTB,S3); //S3
clr(PORTB,S2); //S2 
// Serial.print(" b");
}

else if(color == 3){//green
set(PORTB,S3); //S3
set(PORTB,S2); //S2 
// Serial.print(" g");
}

// wait a bit for LEDs to actually turn on, as directed by sensorDelay var
_delay_ms(100);

// now take a measurement from the sensor, timing a low pulse on the sensor's "out" pin
readPulse = pulseIn();

//if the pulseIn times out, it returns 0 and that throws off numbers. just cap it at 80k if it happens
if(readPulse < 10){
readPulse = 16000;
}

//turn off color sensor and LEDs to save power 
taosMode(0);

// return the pulse value back to whatever called for it... 
return readPulse;

}

/*Operation modes controlled by S0 and S1 pins. setting mode to zero = low power mode.*/

void taosMode(int mode){
    
    if(mode == 0){
    //power OFF mode-  LED off and both channels "low"
    clr(PORTB,S0); //S0
    clr(PORTB,S1); //S1
    //  Serial.println("mOFFm");
    
    }else if(mode == 1){
    //this will put in 1:1, highest sensitivity
    set(PORTB,S0); //S0
    set(PORTB,S1); //S1
    // Serial.println("m1:1m");
    
    }else if(mode == 2){
    //this will put in 1:5
    set(PORTB,S0); //S0
    clr(PORTB,S1); //S1
    //Serial.println("m1:5m");
    
    }else if(mode == 3){
    //this will put in 1:50
    clr(PORTB,S0); //S0
    set(PORTB,S1); //S1 
    //Serial.println("m1:50m");
    }    
}

void TCS3200setup(){
    
    //color mode selection
    set(DDRB,S2); //S2 pinE
    set(DDRB,S3); //s3 pinF
    
    //color response pin (only actual input from taos)
    clr(DDRB,out); //taosOutPin pinC
    
    //communication freq (sensitivity) selection
    set(DDRB,S0); //S0 pinB
    set(DDRB,S1); //S1 pinA 

}

Did you read my sig? It says, "Please don't PM me with technical questions. Post them in the forum". Now please read the replies that told you how to solve your problem.

plz fix that errors

mahi12:
plz fix that errors

Well, you're cocky, aren't you? Are you my boss?

no i m requesting you :frowning:

mahi12:
no i m requesting you :frowning:

...and I'm telling you for the second time that you have already been helped. See reply #4. Also the first sentence of reply #2.

Are you compiling for wrong board too? Some of those errors look like missing register names ( or typos?)

That is not an arduino sketch. It is a straight c program. You will have more issues too. It will be much closer to working in atmel studio.

Look, dude.

You have a file named "final", written by some other person 2 years ago.

It has a bunch of stuff that only a relatively advanced AVR programmer (a non-beginner, anyway) would write: overriding main(), directly talking to ports, bit fiddling operators, talking to fun hardware like LCD screens.

You, clearly, did not write this thing. And you clearly have no clue whatsoever what you are doing and have made no effort to learn to write your own.

You only get to go "plz fix this code" with no further explanation or input if you are my boss. And maybe not even then.

Ok, I'll throw you a bone.: since your code doesn't compile, fix it by replacing the whole thing with this:

void setup() {
}

void loop() {
}

You will find that it compiles just fine, now. Then go through the tutorials in the IDE to find out how to fill in the blanks.

Oh: also learn to spell, although that rule can be relaxed a bit for a non-native english speaker.