Home \ Help \ Search \ Login RSS

Welcome, Guest. Please Login

This forum is now READ-ONLY! Please visit http://forum.wiring.co/ for the new forum.

Wiring ForumProgramming Questions & HelpIntegration › Checking multiple inputs

Page Index Toggle Pages: 1
Checking multiple inputs (Read 4870 times)
03/12/08 at 02:05:34

Vaccumdiode2   Offline
Full Member
chicago, IL USA

Posts: 120
Hello eveybody,
            My wife bought me a neat little kit for Christmas.  It is a 14 channel IR remote kit.  it has a PIC that decodes the IR signal and it will drop the signal on the channel that is activated.  It does not come with a PCB so I had to set it up and lay it out on a prototype board. Since time has been short for working on my robot I finally got the hardware finish yesterday and tested it to night.  now I was going to start on the program. 
             How should I go about scanning the inputs.  If-Else, Case or is there some simpler way.  I will use my 20x4 LCD for a test output.  I'll start with string of If-Else.
              I'll Post more detail in the next few days.

Please post any Ideas that may help me. 

I hope to use it to mamually control my robot.

Thank you

IP Logged
Reply #1 - 03/12/08 at 14:05:24

Alan_Kilian   Offline
Full Member
Wiring? It looks like
Java to me.

Posts: 118
I would split the inputs into two groups and hook each group
to a "port" and then use the portRead(portnumber) function.

Something like this:

unsigned char lowPort = 0;
unsigned char highPort = 1;

loop() {

    if(channelActive(0)) DoWhatecerForChannelZero()
    if(channelActive(1)) DoWhatecerForChannelOne()
    if(channelActive(2)) DoWhatecerForChannelTwo()


    if(channelActive(13)) DoWhatecerForChannelThirteen()

unsigned char
channelActive(unsigned char channelNumber) {
    unsigned char portNumber = lowPort;

    if(channelNumber > 7) {
       portNumber = highPort;
       channelNumber -= 8;

    return(portRead(portNumber) & 1 << channelNumber);
IP Logged
Reply #2 - 03/12/08 at 15:49:32

Vaccumdiode2   Offline
Full Member
chicago, IL USA

Posts: 120
         That looks like the direction I'm look for.  I'll Play with it and let you know.

Here is the info on the kit I'm using.

K92. IR Remote Control & Decoder IC

This Kit uses a commercial 14-pin remote control unit to put an active low signal onto one of 14 pins on a decoder IC. That is, when a RC button is pressed, the pin corresponding to that button on the decoder IC goes low. Normally, each of the 14 output pins is high. It is up to the user to use this information in their own circuit where remote control is required. For example, to control up to 14 relays or to control the movement of a robot. We supply all the necessary extra components
required for the decoder IC to function properly. No PCB is supplied. It is up to the user to breadboard their application then make their own PCB. A sample application/test circuit is provided. A 330W resistor & LED are supplied for testing the active low on a pin in response to a button press.

They supply three sets of components:
1. a 14 button Infra Red Remote Control unit. It just needs you to add 2 x AAA batteries.
2. a 3-pin Infrared Receiver Module, the Waitrony PIC1018SCL which converts the modulated 38kHz signal into data pulses.
3. an Atmel 89C2051-24PC microcontroller which we have preprogrammed to decode the IR data pulses from the remote control into one of 14 active low outputs. All required components for the microcontroller are supplied – a 12MHz ceramic resonator for the oscillator, resistor, capacitor and diode for the power-on reset circuit plus two 10K pullup resistors (see below).

The remote control unit sends out a 38KHz signal modulated with data pulses for the particular button pressed. The infrared receiver module removes the 38KHz signal and outputs the data pulse stream. This is fed into the microcontroller where it is decoded by onboard firmware and one of the fourteen ouputs will go low. The microcontroller outputs are normally held high by internal pullups except for pins 12 and 13 which require external pullup resistors (10K).

The following table lists each pin function.
Pin Description                                    Pin Description
1 RESET, active high                            20 VCC (+5V)
2 Output 14, BUTTON 14                      19 Output 1, BUTTON 1
3 Output 13, BUTTON 13                      18 Output 2, BUTTON 2
4 Ceramic resonator                            17 Output 3, BUTTON 3
5 Ceramic resonator                            16 Output 4, BUTTON 4
6 Data input (from IR receiver module) 15 Output 5, BUTTON 5
7 Output 12, BUTTON 12                      14 Output 6, BUTTON 6
8 Output 11, BUTTON 11                      13 Output 7, BUTTON 7
8 Output 10, BUTTON 10                      12 Output 8, BUTTON 8
10 GND                                              11 Output 9, BUTTON 9
See Their website at http://kitsrus.com
Email Them at peter@kitsrus.com if you have any questions. Yes,
They will supply any extra components you wish. Just email us. The
code inside the decoder IC is locked and is not available.

330R resistor 1/4W 1
10K resistors 1/4W 4
5mm LED 1
1N4148 diode 1
10uF/25V mini ecap 1
12MHz ceramic res. 1
AT89C2051 IC 1
IR Receiver module 1
27pF ceramic caps 2
IR Remote Control 1

IP Logged
Page Index Toggle Pages: 1