Pages: [1]   Go Down
Author Topic: Newbies with Arduino Infrared  (Read 938 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, as the topic shows, I'm a newbie with arduino and have some question with infrared LED VS1838B.

i)I am making a remote controlled mini car using arduino infrared and attempt to control it with left/right, forward/backward. What kind of coding should i use?
ii)And the RX is VS1838B, how should I make a TX? Should I find a TX that same frequency with the RX? or i can just use a simple tx and control both tx and rx by arduino?

I'm a newbie and i really mean it. Please give suggestion to me. Thanks! smiley
Logged

texas
Offline Offline
God Member
*****
Karma: 27
Posts: 862
old, but not dead
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You just need an infrared LED to generate a signal that your receiver can pick up.  There is a library for doing IR remote control, that would probably be the easiest route to go as it will generate the 38kHz carrier for the IR LED.
Logged

Experience, it's what you get when you were expecting something else.

Johannesburg UTC+2
Offline Offline
Faraday Member
**
Karma: 60
Posts: 3242
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Even easier is to use a tv remote and use Ken shirriff's work here to de-code the buttons. Then write a new sketch using the IRremote library to use the buttons' codes to (eg) accelerate, turn, stop etc etc.
Logged

Have you looked for answers in the Learning, Reference, Products and Playground tabs on http://arduino.cc/en/ ?
Look here http://electronicsclub.info/ for basic electronics

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The Ken shirriff's work did help me alot. Thanks! But i still have some question:

i) How should i switch on an led by using the coding? I have no idea to change it. ><
Logged

Johannesburg UTC+2
Offline Offline
Faraday Member
**
Karma: 60
Posts: 3242
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
How should i switch on an led by using the coding? I have no idea to change it. ><

Here's some code I used to make an LED go brighter and dimmer using the "up" and "down" buttons on a tv remote. Note that my particular remote produces 2 codes for each button, alternating on each press.

Code:
/*
 * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
 * An IR detector/demodulator must be connected to the input RECV_PIN.
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff
 * http://arcfn.com
 */
 
/* well now it controls the brightness of an LED
   LED is PWM'd on pin5
   *******   PWM on pin3 seems disabled when using IR?
   uses the volume key... up to brighten, down to dim
   under rc5, the keys have two toggled values
   down:    411 or c11 hex; 1041 or 3089 dec
   up:      410 or c10 hex; 1040 or 3088 dec
*/
               

#include <IRremote.h>

int RECV_PIN = 11;
int led_pin = 5;   // seems PWM not work on 3 with IR library
int led_bright = 130;  //half way to start
int led_step = 10;     // and change in pwm steps of 10

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  pinMode(led_pin, OUTPUT);
  analogWrite(led_pin, led_bright);
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
   
    //now check if it's correct key and act...
    //down
    if (results.value == 1041 || results.value == 3089) {
      led_bright = led_bright - led_step;
      if (led_bright < 10) {
        led_bright = 10;
        }
      Serial.print("Going down to ");
      Serial.println(led_bright);
      analogWrite(led_pin, led_bright);
    }
   
    //up
    if (results.value == 1040 || results.value == 3088) {
      led_bright = led_bright + led_step;
      if (led_bright > 255) {
        led_bright = 255;
      }
      Serial.print("Going up to ");
      Serial.println(led_bright);
      analogWrite(led_pin, led_bright);
    }
  }
}

I eventually used similar coding to control robot motors
Logged

Have you looked for answers in the Learning, Reference, Products and Playground tabs on http://arduino.cc/en/ ?
Look here http://electronicsclub.info/ for basic electronics

Pages: [1]   Go Up
Jump to: