powerpoint page control using the bluetooth
Homepage
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){ } }