![](/media/cache/profiles/0e7702441590ab2e63aab191ba159a84.jpg.50x50_q85.jpg)
powerpoint page control using the bluetooth
Parts
- WIZwiki-W7500ECO : Rerence Document :http://wizwiki.net/wiki/doku.php?id=products:wizwiki-w7500eco:start
- JMODE-BT-1 : - Reference Document : http://eleparts.co.kr/data/design/product_file/Hoon/JCnet/JMOD-BT-1-2.pdf Bluetooth 모듈이라면 뭐든지 상관없습니다.
- Jumper line
- Push Switch
Schematic
Program
- mbed web compiler
- Processing
Software
Link :https://developer.mbed.org/users/eunkyoungkim/code/Bluetooth_PPT_Control/
include the mbed library with this snippet
#include "mbed.h" DigitalOut right_led(PA_1); DigitalOut left_led(PA_2); Serial bt(P13, P14); // tx, rx bool left_flag = false; bool right_flag = false; void left_handler(void) { left_flag = true; } void right_handler(void) { right_flag = true; } int main() { // Disable the battery charger unless a battery is attached. right_led = 1; left_led = 1; bt.baud(115200); InterruptIn leftsw(PC_6); InterruptIn rightsw(PC_7); leftsw.rise(&left_handler); rightsw.rise(&right_handler); while (true) { if (left_flag) { bt.printf("1\n"); left_flag = false; left_led = 0; wait_ms(500); left_led = 1; } if (right_flag) { bt.printf("2\n"); right_flag = false; right_led = 0; wait_ms(500); right_led = 1; } } }
Processing
include the mbed library with this snippet
import processing.serial.*; import java.awt.*; import java.awt.event.KeyEvent; Serial myPort; boolean temp; void setup(){ println(Serial.list()); println(Serial.list()[0]); String portName = Serial.list()[0]; myPort = new Serial(this, portName, 9600); myPort.bufferUntil('\n'); } void draw(){ serialEvent(myPort); } void serialEvent(Serial myPort){ String inputString = myPort.readStringUntil('\n'); try{ inputString = trim(inputString); RobotTest(inputString); }catch(NullPointerException ne){ inputString = "0"; } // 블루투스 통신을 통해 받아온 데이터를 받습니다. } void RobotTest(String temp) { try{ Robot robot = new Robot(); robot.setAutoDelay(1000); if(temp.equals("1")){ robot.keyPress(KeyEvent.VK_RIGHT); } // '1'이 들어왔을 경우 키보드 오른쪽 버튼을 누릅니다. else if(temp.equals("2")){ robot.keyPress(KeyEvent.VK_LEFT); } // '2'가 들어왔을 경우 키보드 왼쪽 버튼을 누릅니다. }catch(Exception e){ } }
/media/uploads/eunkyoungkim/ppt_control_using_bluetooth.mp4
Revision 0:292d2774e9b9, committed 2016-04-01
- Comitter:
- eunkyoungkim
- Date:
- Fri Apr 01 07:46:48 2016 +0000
- Commit message:
- Powerpoint page control using the bluetooth
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Apr 01 07:46:48 2016 +0000 @@ -0,0 +1,48 @@ +#include "mbed.h" + + +DigitalOut right_led(PA_1); +DigitalOut left_led(PA_2); +Serial bt(P13, P14); // tx, rx + +bool left_flag = false; +bool right_flag = false; + +void left_handler(void) { + left_flag = true; +} + +void right_handler(void) { + right_flag = true; +} + +int main() { + // Disable the battery charger unless a battery is attached. + right_led = 1; + left_led = 1; + + bt.baud(115200); + + InterruptIn leftsw(PC_6); + InterruptIn rightsw(PC_7); + leftsw.rise(&left_handler); + rightsw.rise(&right_handler); + + while (true) { + if (left_flag) { + bt.printf("1\n"); + left_flag = false; + left_led = 0; + wait_ms(500); + left_led = 1; + } + if (right_flag) { + bt.printf("2\n"); + right_flag = false; + right_led = 0; + wait_ms(500); + right_led = 1; + } + + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Apr 01 07:46:48 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/c0f6e94411f5 \ No newline at end of file