element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • 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
Community Hub
Community Hub
Member's Forum Serial interrupts not working in arduino....
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Leaderboard
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Community Hub to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 0 replies
  • Subscribers 506 subscribers
  • Views 207 views
  • Users 0 members are here
Related

Serial interrupts not working in arduino....

Former Member
Former Member over 10 years ago

This is my code................

 

int led=13;

int led2=5;

 

 

char dataBuff[10];

int count=0;

boolean b=true;

 

 

 

 

void setup()

{

pinMode(led,OUTPUT);

pinMode(led2,OUTPUT);

 

 

Serial.begin(9600);

delay(100);

 

 

}

 

 

void loop()

{

digitalWrite(led,LOW);

digitalWrite(led2,HIGH);

Serial.write("Waiting for Data");

Serial.println();

 

 

delay(1000);

   

    while(b);

   

digitalWrite(led2,LOW);

digitalWrite(led,HIGH);     

delay(1000);

 

 

Serial.write("The Received Bytes are:");

Serial.println();

Serial.write("Count Value");

Serial.write(count);

Serial.println();

 

 

int i=0;

for(i=0;i<10;i++)

      {

          Serial.write(dataBuff[i]);

          Serial.write("-");

          delay(100);

     

      }

 

 

while(true);

 

 

 

 

}

 

 

 

 

void serialEvent(){

 

  char ch;

    while(Serial.available()>0)

          {

              ch=(char)Serial.read();

              if(ch=='*')          // '*' this indicates end of transmission

                  {

                    b=false;

                    break;

                  }

              if(ch==' ')          // '  ' spaces between bytes of data...

                  {

                      break;

                  }

               dataBuff[count]=ch;

                ++count;  

           

          }

 

 

 

 

 

 

}

 

i am trying to read 8 bytes of data sent serially with 100ms delay in between trasmission from Atmega16 at 9600 There is no problem in Atmega16 i hav tested it using LED set data is comming as i send them ....

But the code is not working the arduino is reading data but not storing it in array of char...? where am i going wrong...and the boolean 'b' value does not get effected..i hav tried declaring count as static but no output and even count value is also not displayed ....and also tried having delay in while loop to break after 10s but still the data buffer is empty....it prints data like '----------'.....Plz help me out here....?

  • Sign in to reply
  • 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