powerpoint page control using the bluetooth

Dependencies:   mbed

Parts

/media/uploads/eunkyoungkim/bluetooth_eco_1.jpg

Schematic

/media/uploads/eunkyoungkim/bluetooth_eco.jpg

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

Download repository: zip gz

Files at revision 0:292d2774e9b9

Name Size Actions
[up]
main.cpp 964 Revisions Annotate
mbed.bld 65 Revisions Annotate