Go Down

Topic: Help!!! (Read 187 times) previous topic - next topic

X234

I´m having problems with my schetch with arduino when I´m trying to uploaded to the board it says that "a function-definition is
Code: [Select]


this is the code
 
#include <IRremote.h>
#include <IRremoteInt.h>

#include <IRremote.h>

int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
int tecla;

void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
{
 for (int i =9 ; i<12 ; i++)
 pinMode(i, OUTPUT);
}

void loop()
{
  if(irrecv.decode(&results))
}
// Serial.println(results.value, HEX);
tecla=results.value; // Obtenemos el valor decimal de la tecla pulsada
Serial.println(tecla);
if (tecla==225) // codigo de la tecla 1
{
 Color(random(255), random(255), random(255)) ;
 delay(500);
  }
if (tecla==-32641) // Codigo de la tecla 2
{    Color(255 ,0 ,0) ;
        delay(500);
        Color(0,255 ,0) ;
        delay(500);
        Color(0 ,0 ,255) ;
        delay(500);
        Color(0,0,0);
        delay(1000);
   }
irrecv.resume(); // Receive the next value
}

void Color(int R, int G, int B)


      {   analogWrite(9 , R) ;   // Rojo
          analogWrite(10, G) ;   // Green - Verde
          analogWrite(11, B) ;   // Blue - Azul
 
      }
not allowed here before '{'

ardy_guy

Your closing brace for setup() is right at the bottom so it thinks loop() starts inside setup().

[irishAccent]Have you tried turning it off and on again?[/irishAccent]

nagdrn

Your " loop() " function is inside " setup() " function.
Try adding a brace to close your setup() function just after the " for " loop.
One question: why do you have a right brace " } " after the first if condition in your loop() function?
I suggest to comment it out.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy