Loading...
Welcome,
Guest
. Please
login
or
register
.
May 22, 2013, 07:10:42 pm
|
Arduino Forum
::
Using Arduino
::
Programming Questions
:: rc5-led
« previous topic
next topic »
Pages: [
1
]
Go Down
Print
Author
Topic: rc5-led (Read 399 times)
0 Members and 1 Guest are viewing this topic.
Jack
0
Offline
Newbie
Karma: 0
Posts: 8
Arduino rocks
rc5-led
«
on:
February 03, 2011, 01:26:42 pm »
Bigger
Smaller
Reset
Hi all.
The led on pin3 must go on and off by a signal from my RC5 when i push on the number 1.
My program is not working.
What is wrong?
Regards,
Jack.
// rc5_2a ( febr. 2011)
#include <IRremote.h>
#include <IRremoteInt.h>
int ledPin = 3;
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
if (results.value = 1) {
digitalWrite(ledPin,LOW);
}
else {
digitalWrite(ledPin,HIGH);
irrecv.resume(); // Receive the next value
}
}
Logged
AlphaBeta
Norway@Oslo
Offline
Edison Member
Karma: 11
Posts: 2033
loveArduino(true);
Re: rc5-led
«
Reply #1 on:
February 03, 2011, 02:35:22 pm »
Bigger
Smaller
Reset
How does your program behave now? Does it print anything? If so; what?
Logged
Jack
0
Offline
Newbie
Karma: 0
Posts: 8
Arduino rocks
Re: rc5-led
«
Reply #2 on:
February 03, 2011, 04:10:03 pm »
Bigger
Smaller
Reset
Yess,it print the value in Hex from the key's a press, but the led on pin3 does nothing.
Jack.
Logged
AlphaBeta
Norway@Oslo
Offline
Edison Member
Karma: 11
Posts: 2033
loveArduino(true);
Re: rc5-led
«
Reply #3 on:
February 03, 2011, 04:49:56 pm »
Bigger
Smaller
Reset
Code:
// rc5_2a ( febr. 2011)
#include <IRremote.h>
#include <IRremoteInt.h>
int ledPin = 3;
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
if (results.value = 1) {
digitalWrite(ledPin,!digitalRead(ledPin));
}
irrecv.resume(); // Receive the next value
}
}
How about that?
Logged
Jack
0
Offline
Newbie
Karma: 0
Posts: 8
Arduino rocks
Re: rc5-led
«
Reply #4 on:
February 04, 2011, 03:08:45 am »
Bigger
Smaller
Reset
Hallo AlphaBeta.
There is progres but the led on pin3 is on by push on button 1 but also by push by all the other key's! The Serial monitor give's the good values.
What to do?
Jack.
Logged
AlphaBeta
Norway@Oslo
Offline
Edison Member
Karma: 11
Posts: 2033
loveArduino(true);
Re: rc5-led
«
Reply #5 on:
February 04, 2011, 06:18:41 am »
Bigger
Smaller
Reset
Like this:
Code:
// rc5_2a ( febr. 2011)
#include <IRremote.h>
#include <IRremoteInt.h>
int ledPin = 3;
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
if (results.value == 1) {
digitalWrite(ledPin,!digitalRead(ledPin));
}
irrecv.resume(); // Receive the next value
}
}
Logged
Pages: [
1
]
Go Up
Print
« previous topic
next topic »
|
Arduino Forum
::
Using Arduino
::
Programming Questions
:: rc5-led
Jump to:
Please select a destination:
-----------------------------
General Category
-----------------------------
=> General Discussion
-----------------------------
Using Arduino
-----------------------------
=> Installation & Troubleshooting
=> Project Guidance
=> Programming Questions
=> General Electronics
=> LEDs and Multiplexing
=> Displays
=> Audio
=> Motors, Mechanics, and Power
=> Sensors
=> Networking, Protocols, and Devices
=> Interfacing w/ Software on the Computer
-----------------------------
Topics
-----------------------------
=> E-Textiles and Craft
=> Robotics
=> Science and Measurement
=> Home Automation and Networked Objects
=> Device Hacking
=> Education and Teaching
=> Interactive Art
=> Product Design
-----------------------------
Development
-----------------------------
=> Suggestions for the Arduino Project
=> Other Hardware Development
=> Other Software Development
-----------------------------
Community
-----------------------------
=> Website and Forum
=> Products and Services
=> Gigs and Collaborations
=> Workshops and Events
=> Local Groups
=> Exhibition / Gallery
=> Bar Sport
-----------------------------
International
-----------------------------
=> Deutsch
=> Español
=> Français
=> Italiano
=> Portugues
=> Scandinavia
-----------------------------
Forum 2005-2010 (read only)
-----------------------------
===> Uno Punto Zero
===> Bar Sport
===> Frequently-Asked Questions
===> News
===> Exhibition
===> Workshops
===> Interfacing
===> Bugs & Suggestions
===> Development
===> Troubleshooting
===> Portugues
===> Deutsch
===> Español
===> Français
===> Italiano
===> Scandinavia
===> Development
===> Interfacing
===> Syntax & Programs
===> Bugs & Suggestions
===> Troubleshooting
===> Report Spam at Arduino.cc
===> Forum
===> Playground Wiki
=> General
=> Hardware
=> Software
=> International
=> Web/Forum/Email/Spam
-----------------------------
Using Arduino
-----------------------------
=> Storage
=> Microcontrollers
-----------------------------
International
-----------------------------
===> Humor y Debate
===> Talleres, Encuentros, ...
===> Tutoriels et cours
===> Réalisations et Projets Finis
===> Le bar
=> Nederlands
===> Software
===> Hardware
===> Proyectos
===> Documentación
=> India
===> Hardware
===> Software
===> Megatopic
-----------------------------
Products
-----------------------------
=> The Arduino Starter Kit
=> Arduino Due
-----------------------------
International
-----------------------------
===> Generale
-----------------------------
Products
-----------------------------
=> Arduino Esplora
=> Arduino GSM Shield
-----------------------------
Maker Faire Rome - The European Edition
-----------------------------
=> Makers
=> Events and Tour
Loading...