new to Ardunio but trying to compile

Status
Not open for further replies.

MrDEB

Well-Known Member
here is my short code that shows an error in line 23 (something about error 302?)
have two books Ardunio programming in 24 hours and Ardunio cook book but no solution? Tried typing code but this 302??
Code:
#include <IRremote.h>

int IRpin = 8;
IRrecv irrecv(IRpin);
decode_results results;


void setup()
{
    Serial.begin(9600);
    irrecv.enableIRIn(); // Start the receiver
}  
void loop() 
{   
    if (irrecv.decode(&results)) 
        {
         Serial.println(results.value); // Print the Serial 'results.value'
          delay(10);

         irrecv.resume();   // Receive the next value
       }
}
 
Is that ALL your code ? There's only 22 lines of code shown ?

Loaded it into Arduino IDE and it compiled without issue ?

MM
 
There has to be empty line after the last curly bracket..
 
still won't must be missing something??
 

Attachments

  • Screenshot (18).png
    110.2 KB · Views: 401
Did you actually read any of those search results?

You have a stray non-prinitable character in your code. Most likely at the start or end, from copy/pasting.
 
Did you copy&paste this code from someplace, or did you install the IRremote library and find this code in the Arduino Examples directory? I suspect it was copy&paste because this error wouldn't have come from a sketch in the example folder.

So, if you copy&paste the code from somewhere, you actually grabbed too much. You got some extra characters either at the beginning of the code or most likely at the end. HTML uses invisible characters to control formatting.

The code you've posted here reportedly works without problem, but you copy&pasted the code to post it here, so you may not have happened to include this invisible character, so testing the code you posted doesn't prove anything.

So, the options are:

o Install the IRremote library, and use examples out of the Arduino example folder.

o Start absolutely fresh with a new blank sketch and copy the file again, being certain to only copy from the first letter to the last without any extra blank space or any other characters.


I have used Arduino enough to know it's a major pain in the butt compared to Swordfish. There are many levels of complexity, starting with the need to install libraries. Proper formatting of the code has been really confusing to me.
 
Copy the whole program to Notepad.

Delete the original.
Copy and paste it back from notepad to the editor.

That should remove any invisible non-ASCII characters.

(Note, Notepad, NOT "wordpad" or any other editor!)
 
Dies Note Pad still do this? I used to do this all the time to remove formatting but I thought recent versions were not such good "cleansers", perhaps when it included unicode support?
 
I agree with WP100.. There will be no library available for the code....

NOW!!! We all need to take a deep breath... MrDeb is now doing what we all asked him to do.. Hold off with the negativeness..

MrDEB.. In the menu look for "Include Library " then select manager and type "IRremote" and click install.
 
My plan is to re type entire code but this notepad++.
need to look at that.
As for library, I have the correct library and recent IDE. I think its 1.8?
 
I copied your code to notepad++ and there are no spurious characters.... Weird!!
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…