My project on arduino

Hello guys

I have a question/problem with one arduino project(this is not the full project, but just the part thats not working).
So.... I am working with IR receiver and a remote. The program is: until one of the buttons on the remote isn't pressed, a red led should be ON. When a button gets pressed on a remote, the red led should turn OFF. But it wont turn off. It stays on. I dont know where I screwed up....
It sound easy, and it is, but it wont work. I am still learning....

Here is the program:

#include <IRremote.h>

const int RECV_PIN = 8;
IRrecv irrecv(RECV_PIN);
decode_results results;
const int redPin = 6;

void setup(){
irrecv.enableIRIn();
irrecv.blink13(true);
pinMode(redPin, OUTPUT);
}

void loop(){
digitalWrite(redPin, HIGH);
if(irrecv.decode(&results)){
digitalWrite(redPin, LOW);

irrecv.resume();
}
}

Thanks in advance

start by reading the bottom part of my signature line

  if(irrecv.decode(&results))

I would put this right below the line above to see what values are derived that lead to the results I got.

Serial.print(irrecv.decode); Serial.print(results); Serial.println(irrecv.decode(&results));

So uh... I um... this is what I did, if thats what you meant:

#include <IRremote.h>
const int RECV_PIN = 8;
IRrecv irrecv(RECV_PIN);
decode_results results;
const int redPin = 6;

void setup(){
irrecv.enableIRIn();
Serial.begin(9600);
irrecv.blink13(true);
pinMode(redPin, OUTPUT);
}

void loop(){
digitalWrite(redPin, HIGH);
if(irrecv.decode(&results)){
Serial.println(irrecv.decode(&results));
digitalWrite(redPin, LOW);

irrecv.resume();
}
}

When I go to serial monitor, it prints only "1".
Thanks for the quick reply

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html . Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom... :slight_smile:

Hello
I read the instructions. Sorry about that...

Currently I am doing my project on tinkercad, because I have some problems with my arduino.
Here is my picture of everything I am working with on my project in tinkercad:

Ehh.... hopefully there is an image above this. Anyway... yea.

Hi,
You would be better to attach your image to the post.

Tom... :slight_smile:

let me amend that: add

Serial.print("irrecv.decode ", irrecv.decode); Serial.print("results ", results); Serial.println("whatever you think this will do "irrecv.decode(&results));

to void loop() in this fashion:

void loop(){
  digitalWrite(redPin, HIGH);
  if(irrecv.decode(&results)){
     Serial.print("irrecv.decode " , irrecv.decode);
     Serial.print("results ", results); 
     Serial.println("whatever you expect this do ", irrecv.decode(&results));
  digitalWrite(redPin, LOW);
   
      irrecv.resume();
    }
}

it works better if you label what it is you're seeing. Study Serial.print(F(... which is a better way to do this

Hi. Here is an attachment of my circuit.

The code you sent doesn't work. I'm sorry, but I cant send you the error. On tinkercad I cant copy it.
It just marks this part of the code red:

Serial.print("irrecv.decode " , irrecv.decode);
Serial.print("results ", results);
Serial.println("whatever you expect this do ", irrecv.decode(&results));

I'll put the attachment of that image too, but the error is really long.
I would do this in normal arduino application, but my arduino is going to arrive next monday.
Maybe tinkercad is the problem, and not the hole code.
Anyway, thanks guys. Sorry I cant give you more information... :frowning:

Ah.. didn't use the "code"

Serial.print("irrecv.decode " , irrecv.decode);
     Serial.print("results ", results); 
     Serial.println("whatever you expect this do ", irrecv.decode(&results));

Hi,
OPs images;


Tom... :slight_smile: