Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SPP.h>
- USB Usb;
- BTD btd(&Usb);
- SPP SerialBT(&btd,"PDM Arduino","0001");
- boolean firstMessage = true;
- void setup() {
- Serial.begin(115200);
- if (Usb.Init() == -1){
- Serial.print(F("\r\nOSC did not start"));
- while(1);
- }
- Serial.print(F("\r\nSPP Bluetooth started"));
- }
- void loop() {
- Usb.Task();
- if(SerialBT.connected){
- if(firstMessage){
- firstMessage = false;
- SerialBT.println(F("Hello from Arduino"));
- Serial.println("HELLO!");
- /*
- for( int i = 0; i < 256; i++){
- Serial.print("0x");
- Serial.print(i,HEX);
- Serial.print(" - ");
- Serial.write(i);
- Serial.println();
- }
- */
- }
- if(Serial.available()){
- SerialBT.print((char)Serial.read());
- }
- if(SerialBT.available()){
- Serial.print("Tilgaengelig:");
- Serial.println(SerialBT.available());
- int times = 0;
- while(SerialBT.available()){
- char k = SerialBT.read();
- times++;
- char c = (char)k;
- if(c == '0' || c == '1' ||c == '2' ||c == '3' ||c == '4' ||c == '5' ||c == '6' ||c == '7' ||c == '8' ||c == '9'){
- }
- else{
- Serial.println();
- Serial.print("Fejl:");
- Serial.print(times);
- Serial.print(" - 0x");
- Serial.print(c,HEX);
- }
- }
- }
- }
- else{
- firstMessage = true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement