element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Code Exchange
  • Technologies
  • More
Code Exchange
Documents i have made this code for receive string and store it into an array then comparing it to perform task but its not working.help me to get eny sollution
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Code Exchange to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Engagement
  • Author Author: gk.rajatc
  • Date Created: 26 May 2020 10:04 AM Date Created
  • Last Updated Last Updated: 6 Oct 2021 10:22 PM
  • Views 658 views
  • Likes 0 likes
  • Comments 1 comment
Related
Recommended

i have made this code for receive string and store it into an array then comparing it to perform task but its not working.help me to get eny sollution

#ifndef F_CPU

#define F_CPU 8000000UL // 16Mhz clock speed

#endif

#include <avr/io.h>

#include <util/delay.h>

#include <string.h>

//#define USART_BAUDRATE 9600

#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) -1)

#define LED_ON  PORTD |= (1<<PIND6);

#define LED_OFF6  PORTD &= ~(1<<PIND6);

 

 

volatile unsigned char string[15],x,i =0;

volatile char Reply_CallReady[15]="apple";

volatile char C;

volatile char data[10];

 

 

void UART_init(long USART_BAUDRATE)

{

UCSRB |=(1<<RXEN)|(1<<TXEN)|(1<<RXCIE);//TURN ON TRANSMISSION AND RECEPTION.

UCSRC |=(1<<URSEL)|(1<<UCSZ0)|(1<<UCSZ1);//USE 8 BIT CHARACTER.

UBRRL |=(BAUD_PRESCALE);//LOAD LOWER 8 BITS OF THE BAUD RATE VALUE.

UBRRH |=(BAUD_PRESCALE>>8);//LOAD UPPER 8 BIT.

}

unsigned char UART_Rxchar()

{

while((UCSRA & (1<<RXC))==0);//wait till data is received.

return(UDR);//RETURN THE BYTE.

}

void UART_Txchar(char ch)

{

while (!(UCSRA & (1<<UDRE)));//wait for empty transmit buffer.

UDR=ch;

 

}

void UART_sendstring(char *str)

{

unsigned char j=0;

while(str[j]!=0)     // send string till null.

{

UART_Txchar(str[j]);

j++;

}

}

void lcd_cmd(char cm)

{

char a=cm;

PORTA=a;

PORTB=(0<<PD0)|(0<<PD1)|(1<<PD2);

_delay_ms(50);

PORTB=(0<<PD0)|(0<<PD1)|(0<<PD2);

}

void lcd_data(char dat)

{

char b=dat;

PORTA=b;

PORTB=(1<<PD0)|(0<<PD1)|(1<<PD2);

_delay_ms(50);

PORTB=(1<<PD0)|(0<<PD1)|(0<<PD2);

_delay_ms(50);

}

 

 

unsigned char *UART_RX_STR(x)

{

while (x != '\0')

{

string[i++] = x;

}

return string;

 

 

}

 

 

 

 

 

 

ISR(USART_RXC_vect)

{

C=UDR;

}

 

 

int main()

{

DDRB=0xFF;

DDRA=0xFF;

 

UART_init(9600);

while(1)

{

C=UART_Rxchar();

x=C;

if (strcmp(string,Reply_CallReady) ==0)

{

LED_ON;

 

 

}

else

{

LED_OFF6;

}

 

 

}

}

  • Code Exchange
  • Share
  • History
  • More
  • Cancel
  • Sign in to reply
  • shabaz
    shabaz over 5 years ago

    Hi Rajat,

     

    It isn't easily readable, please can you edit the discussion and use the code syntax highlighting tool, and paste in code so that tabs or spaces are intact?

    Information on how to find the syntax highlighting tool is here:

    How to Ask Questions using the Create Discussion tool

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube