StarBoard Orange : "Application example No.2 : Add many buttons to your application with IR remote!"
.
Languages
日本語版はこちら : ☆ボードオレンジ:「活用事例2:赤外線リモコンで楽々操作しよう!」
Overview
StarBoard Orange have no buttons. Because some users don't need any buttons for their applications.
So, The board designer didn't add any buttons to StarBoard Orange. It's good choice for the versatility.
But... sometime we need buttons for a application. We can add a button to unused pin on mbed.
This is a not so good choice for StarBoard Orange. Because a good point of StarBoard Orange is its compactness.
I recommend you to add an IR receiver to your StarBoard Orange.
By this solution, You can be use many buttons without wasting much spaces and many pins of mbed.
You can control your mbed and your applications by remote controller like a TV!
And you can use IR class library in another applications you designed.
Setup
Necessary parts
- StarBoard Orange
- mbed NXP LPC1768
- IR sensor (PL-IRM2121-A538 or PL-IRM0101-3 or CRVP1738)
Environments
- IR remote commander (e.g. : SONY RM-PZ1FD)
Programs
Import following program to your compiler
http://mbed.org/users/shintamainjp/programs/StarBoardOrangeExample2/latest
Equipments
You need IR remote controllers
You may have many remote controllers in your house, probably I think. Find it! :)
Put on a IR sensor to your StarBoard Orange
Put on a IR sensor to your StarBoard Orange. In my case, I used PL-IRM2121-A538.
You can use a breadboard to connect an IR sensor with wires.
It is easy to setup for this solution.
Start the program
The example application supports 3 IR remote controller protocols, NEC, AEHA, and SONY.
Compile the application example on your compiler page, and run it on your mbed with your StarBoard Orange.
- The application display a message "Press a button on a controller" after reset.
- Press a button on a remote controller.
- Then the data will be appear in LCD.
- The pattern of LED changed per a sample.
Example movie
Movie
A following movies show how example applications look like. The remote controller is RM-PZ1FD made by SONY.
The remote controller can change output signal mode. It have so many configurations.
Here is the configurations in this movie.
Configuration number | TV Maker | Protocol |
412 | Hitachi | NEC |
411 | Panasonic | AEHA |
211 | SONY | SONY |
In this sample application, the following data will be displayed on the LCD.
From upper left: State, Received bit count, Protocol type.
Bottom of line: Received data.
Example display
Example display for NEC protocol
Example display for AEHA protocol
Example display for SONY protocol
To use class of IR receiver
Overview of the class
It's easy to use the class of IR receiver.
The constructor needs a pin for the input.
ReceiverIR ir(p17);
And check the state, if the state is ReceiverIR::Received, then you can read the data.
if (ReceiverIR::Received == ir.getState()) { ReceiverIR::Format format; uint8_t buf[32]; int bc = ir.getData(&format, buf, sizeof(buf)); }
The return value bc is bit count of received data.
Example codes
Here is the example codes.
while (1) { static int latest_bits = 0; static ReceiverIR::State prev = ReceiverIR::Idle; /* * Get a current state. */ ReceiverIR::State curr = ir.getState(); if (prev != curr) { lcd.locate(0, 0); switch (curr) { case ReceiverIR::Idle: lcd.printf("Idle (%2d) \n", latest_bits); break; case ReceiverIR::Receiving: lcd.printf("Receiving \n"); break; case ReceiverIR::Received: lcd.printf("Received \n"); break; } } prev = curr; /* * Update statuses if it updated. */ if (ReceiverIR::Received == curr) { led = led + 1; ReceiverIR::Format format; uint8_t buf[32]; int bc = ir.getData(&format, buf, sizeof(buf)); latest_bits = bc; lcd.locate(10, 0); switch (format) { case ReceiverIR::UNKNOWN: lcd.printf(": ????"); break; case ReceiverIR::NEC: lcd.printf(": NEC "); break; case ReceiverIR::AEHA: lcd.printf(": AEHA"); break; case ReceiverIR::SONY: lcd.printf(": SONY"); break; default: break; } lcd.locate(0, 1); for (int i = 0; i < (bc / 8); i++) { lcd.printf("%02X", buf[i]); } for (int i = 0; i < 8 - (bc / 8); i++) { lcd.printf("--"); } } }
Summary
- You can use many buttons of IR remote controllers.
- This solution provides a user control from a distance.
- The classes for IR remote receiver can re-use in your applications.
References
Basic information
- StarBoard Orange: mbed評価用ベースボード(in Japanese)
- StarBoard Orange : "Soldering step by step"
- StarBoard Orange : "Expandability of StarBoard"
Application examples
- StarBoard Orange : "Application example No.1 : Enjoy mbed world with just one sensor!"
- StarBoard Orange : "Application example No.2 : Add many buttons to your application with IR remote!"
- StarBoard Orange : "Application example No.3 : Drive a CHORO Q with wii nunchuck!"
Related documents
Update history
Version | Date | Description |
1.0.0 | 2010/08/13 | First version. |
1.0.1 | 2010/08/14 | Added application examples to references. |
1.0.2 | 2010/08/16 |
Fixed name of StarBoard Orange. |
1.0.3 | 2010/08/16 | Translated. |
1.0.4 | 2010/08/22 | Added checked model PL-IRM0101-3. Added related documents to references. |
1.0.5 | 2010/09/09 | Updated english words. |
1.0.6 | 2010/09/10 | Updated links of application examples. |
- | - | - |
- | - | - |
1 comment
You need to log in to post a comment