# Make timer state ON and timer state OFF Android to Arduino via bluetooth

**URL:** https://discourse.processing.org/t/make-timer-state-on-and-timer-state-off-android-to-arduino-via-bluetooth/28668
**Category:** Electronics (Arduino, etc.)
**Tags:** homework
**Created:** [March 19, 2021, 10:24pm UTC](https://discourse.processing.org/t/make-timer-state-on-and-timer-state-off-android-to-arduino-via-bluetooth/28668 "2021-03-19T22:24:54Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![r0x15](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@r0x15](https://discourse.processing.org/u/r0x15)
#### Post date: [March 19, 2021, 10:24pm UTC](https://discourse.processing.org/t/make-timer-state-on-and-timer-state-off-android-to-arduino-via-bluetooth/28668/1 "2021-03-19T22:24:54Z")

</div>

Who help me code example for:  
Make timer state ON and timer state OFF Android to Arduino via bluetooth

---

<div class="post-metadata">

### Author: ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)
#### Post date: [March 20, 2021, 11:04pm UTC](https://discourse.processing.org/t/make-timer-state-on-and-timer-state-off-android-to-arduino-via-bluetooth/28668/2 "2021-03-20T23:04:37Z")

</div>

Hi,

Can you be more descriptive about the intent of your project? What is it for? What does it mean for a timer to have an ON/OFF state? Do you already have a setup / code to show us?

Also for the Arduino to be connected by bluetooth, you need to have a bluetooth module and a library to receive/send messages to your computer running Processing.

Doing a simple research on Internet give me those results :

> **[Proyecto: Arduino + Processing + Bluetooth HC-05](https://www.hackster.io/victruino/proyecto-arduino-processing-bluetooth-hc-05-8039d6)**
>
> Bluetooth communication between Arduino and the PC using a small interface programmed in Processing. By victruino.

> <https://stackoverflow.com/questions/56158464/processing-bluetooth-to-arduino>

> **[PROCESSING AND ARDUINO VIA BLUETOOTH » Alis | Interaction Design Studio](https://alis.design/processing-and-arduino-via-bluetooth/)**

That’s why giving a simple code example is complicated 😉

Also if it’s a homework assignment, please read the [FAQ](https://discourse.processing.org/faq).

Have fun!

---

<div class="post-metadata">

### Author: ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)
#### Post date: [March 21, 2021, 12:01am UTC](https://discourse.processing.org/t/make-timer-state-on-and-timer-state-off-android-to-arduino-via-bluetooth/28668/3 "2021-03-21T00:01:22Z")

</div>

i made this

```auto
import ketai.net.bluetooth.*;
import controlP5.*;
import android.os.Bundle;

ControlP5 cP5a;
ControlP5 cP5b;

String device_name = "HC-05";
//String device_mac = "40:45:DA:00:25:05";

KetaiBluetooth bt;

void setup() { 
  cP5a = new ControlP5(this);
  cP5a.addSlider("CYCLE_TIME", 999, 1999,999, 10, 10, 255, 35);
  cP5b = new ControlP5(this);
  cP5b.addSlider("PULSE", 55, 455, 55, 10, 55, 255, 35);
  bt.getPairedDeviceNames();
  bt.start();
  //bt.connectDevice("40:45:DA:00:25:05");
  bt.connectToDeviceByName(device_name);
}

void draw() {
}

void controlEvent(ControlEvent theEvent) {
  if (theEvent.isController()) {
    print("control event from : "+theEvent.getController().getName());
    println(", value : "+theEvent.getController().getValue());
    if (theEvent.getController().getName()=="CYCLE_TIME") {
      int val1 = int(theEvent.getController().getValue());
      send("a" + val1+"\n");
    }
    if (theEvent.getController().getName()=="PULSE") {
      int val2 = int(theEvent.getController().getValue());
      send("b" + val2+"\n");
    }
  }
}

void send(String str) {
  byte[] data = str.getBytes();
  //bt.write(device_mac, data);
  bt.writeToDeviceName(device_name, data);
  //OscMessage m = new OscMessage(str);
  //bt.broadcast(m.getBytes());
}

void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  bt = new KetaiBluetooth(this);
}

```

this is arduino side

```auto
void loop() {  
    if (Serial.available() >= 2)
   {
    int value2;
    char command = Serial.read();
    switch (command)
    {
    case 'a': value2 = Serial.parseInt();
     d = value2;
       } 
      break;

    case 'b': value2 = Serial.parseInt();
     f = value2;
         }
       break;
 }

```

you can use the d and f values as you want

and you can change the 2 sliders with buttons

---

<div class="post-metadata">

### Author: ![r0x15](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@r0x15](https://discourse.processing.org/u/r0x15)
#### Post date: [March 21, 2021, 6:56pm UTC](https://discourse.processing.org/t/make-timer-state-on-and-timer-state-off-android-to-arduino-via-bluetooth/28668/4 "2021-03-21T18:56:00Z")

</div>

Good evening  
Thanks for the pricey information  
I made a timer with lcd on arduino  
I would like to do it on android as a graphic part and via bluetooth communicate with arduino  
this is the link of the timer I made  
Thank you!!!

[![](https://img.youtube.com/vi/53BYdbbe5rg/maxresdefault.jpg "Without RTC On and Off timer using Arduino and 6x2 LCD Display") ](https://www.youtube.com/watch?v=53BYdbbe5rg)

---

<div class="post-metadata">

### Author: ![r0x15](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@r0x15](https://discourse.processing.org/u/r0x15)
#### Post date: [March 22, 2021, 4:40pm UTC](https://discourse.processing.org/t/make-timer-state-on-and-timer-state-off-android-to-arduino-via-bluetooth/28668/5 "2021-03-22T16:40:06Z")

</div>

Jafal  
Tankyou for code  
But decise i try to compile whit APDE but give me error:

Initializing build sequence…  
Deleted old build folder  
No library found for ketai.net.bluetooth  
No library found for controlP5  
Injected log broadcaster  
Detected architecture armeabi-v7a

## Packaging resources with AAPT… Compiling with ECJ…

1. ERROR in /data/user/0/com.calsignlabs.apde/app\_build/src/processing/test/sketch\_20210202a/sketch\_20210202a.java (at line 8)  
import ketai.net.bluetooth.\*;  
^^^^^  
The import ketai cannot be resolved

* * *

1. ERROR in /data/user/0/com.calsignlabs.apde/app\_build/src/processing/test/sketch\_20210202a/sketch\_20210202a.java (at line 9)  
import controlP5.\*;  
^^^^^^^^^  
The import controlP5 cannot be resolved

* * *

1. ERROR in /data/user/0/com.calsignlabs.apde/app\_build/src/processing/test/sketch\_20210202a/sketch\_20210202a.java (at line 27)  
ControlP5 cP5a;  
^^^^^^^^^  
ControlP5 cannot be resolved to a type

* * *

1. ERROR in /data/user/0/com.calsignlabs.apde/app\_build/src/processing/test/sketch\_20210202a/sketch\_20210202a.java (at line 28)  
ControlP5 cP5b;  
^^^^^^^^^  
ControlP5 cannot be resolved to a type

* * *

1. ERROR in /data/user/0/com.calsignlabs.apde/app\_build/src/processing/test/sketch\_20210202a/sketch\_20210202a.java (at line 33)  
KetaiBluetooth bt;  
^^^^^^^^^^^^^^  
KetaiBluetooth cannot be resolved to a type

* * *

1. ERROR in /data/user/0/com.calsignlabs.apde/app\_build/src/processing/test/sketch\_20210202a/sketch\_20210202a.java (at line 36)  
cP5a = new ControlP5(this);  
^^^^  
ControlP5 cannot be resolved to a type

* * *

1. ERROR in /data/user/0/com.calsignlabs.apde/app\_build/src/processing/test/sketch\_20210202a/sketch\_20210202a.java (at line 36)  
cP5a = new ControlP5(this);  
^^^^^^^^^  
ControlP5 cannot be resolved to a type

* * *

1. ERROR in /data/user/0/com.calsignlabs.apde/app\_build/src/processing/test/sketch\_20210202a/sketch\_20210202a.java (at line 37)  
cP5a.addSlider(“CYCLE\_TIME”, 999, 1999,999, 10, 10, 255, 35);  
^^^^  
ControlP5 cannot be resolved to a type

* * *

1. ERROR in /data/user/0/com.calsignlabs.apde/app\_build/src/processing/test/sketch\_20210202a/sketch\_20210202a.java (at line 38)  
cP5b = new ControlP5(this);  
^^^^  
ControlP5 cannot be resolved to a type

* * *

1. ERROR in /data/user/0/com.calsignlabs.apde/app\_build/src/processing/test/sketch\_20210202a/sketch\_20210202a.java (at line 38)  
cP5b = new ControlP5(this);  
^^^^^^^^^  
ControlP5 cannot be resolved to a type

* * *

1. ERROR in /data/user/0/com.calsignlabs.apde/app\_build/src/processing/test/sketch\_20210202a/sketch\_20210202a.java (at line 39)  
cP5b.addSlider(“PULSE”, 55, 455, 55, 10, 55, 255, 35);  
^^^^  
ControlP5 cannot be resolved to a type

* * *

1. ERROR in /data/user/0/com.calsignlabs.apde/app\_build/src/processing/test/sketch\_20210202a/sketch\_20210202a.java (at line 40)  
bt.getPairedDeviceNames();  
^^  
KetaiBluetooth cannot be resolved to a type

* * *

1. ERROR in /data/user/0/com.calsignlabs.apde/app\_build/src/processing/test/sketch\_20210202a/sketch\_20210202a.java (at line 41)  
bt.start();  
^^  
KetaiBluetooth cannot be resolved to a type

* * *

1. ERROR in /data/user/0/com.calsignlabs.apde/app\_build/src/processing/test/sketch\_20210202a/sketch\_20210202a.java (at line 43)  
bt.connectToDeviceByName(device\_name);  
^^  
KetaiBluetooth cannot be resolved to a type

* * *

1. ERROR in /data/user/0/com.calsignlabs.apde/app\_build/src/processing/test/sketch\_20210202a/sketch\_20210202a.java (at line 49)  
public void controlEvent(ControlEvent theEvent) {  
^^^^^^^^^^^^  
ControlEvent cannot be resolved to a type

* * *

1. ERROR in /data/user/0/com.calsignlabs.apde/app\_build/src/processing/test/sketch\_20210202a/sketch\_20210202a.java (at line 67)  
bt.writeToDeviceName(device\_name, data);  
^^  
KetaiBluetooth cannot be resolved to a type

* * *

1. ERROR in /data/user/0/com.calsignlabs.apde/app\_build/src/processing/test/sketch\_20210202a/sketch\_20210202a.java (at line 74)  
bt = new KetaiBluetooth(this);  
^^  
KetaiBluetooth cannot be resolved to a type

* * *

1. ERROR in /data/user/0/com.calsignlabs.apde/app\_build/src/processing/test/sketch\_20210202a/sketch\_20210202a.java (at line 74)  
bt = new KetaiBluetooth(this);  
^^^^^^^^^^^^^^  
KetaiBluetooth cannot be resolved to a type

* * *

18 problems (18 errors)  
Compiling with ECJ failed

---

<div class="post-metadata">

### Author: ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)
#### Post date: [March 22, 2021, 4:45pm UTC](https://discourse.processing.org/t/make-timer-state-on-and-timer-state-off-android-to-arduino-via-bluetooth/28668/6 "2021-03-22T16:45:52Z")

</div>

download ketai controlP5 libraries to your  
sketchbook

---

<div class="post-metadata">

### Author: ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)
#### Post date: [March 22, 2021, 4:54pm UTC](https://discourse.processing.org/t/make-timer-state-on-and-timer-state-off-android-to-arduino-via-bluetooth/28668/7 "2021-03-22T16:54:35Z")

</div>

> **[Ketai.zip](https://drive.google.com/file/d/19GXV5Rn20IFKTAC3Fmdv8Zuw898jYFV3/view)**
>
> Google Drive file.

---

<div class="post-metadata">

### Author: ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)
#### Post date: [March 22, 2021, 5:44pm UTC](https://discourse.processing.org/t/make-timer-state-on-and-timer-state-off-android-to-arduino-via-bluetooth/28668/8 "2021-03-22T17:44:48Z")

</div>

![3570647d885338c0a1105fbc6385312249080ebe_2_468x750](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/4/448d2787644aa3f54413112538eff784a1933865.jpeg)

---

<div class="post-metadata">

### Author: ![r0x15](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@r0x15](https://discourse.processing.org/u/r0x15)
#### Post date: [March 22, 2021, 9:52pm UTC](https://discourse.processing.org/t/make-timer-state-on-and-timer-state-off-android-to-arduino-via-bluetooth/28668/9 "2021-03-22T21:52:40Z")

</div>

yes i download .  
is possible have one timer HH:MM:SS  
?  
tnx

---

<div class="post-metadata">

### Author: ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)
#### Post date: [March 22, 2021, 9:56pm UTC](https://discourse.processing.org/t/make-timer-state-on-and-timer-state-off-android-to-arduino-via-bluetooth/28668/10 "2021-03-22T21:56:21Z")

</div>

one timer where you mean ?

---

<div class="post-metadata">

### Author: ![r0x15](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@r0x15](https://discourse.processing.org/u/r0x15)
#### Post date: [March 22, 2021, 9:58pm UTC](https://discourse.processing.org/t/make-timer-state-on-and-timer-state-off-android-to-arduino-via-bluetooth/28668/11 "2021-03-22T21:58:22Z")

</div>

![immagine_2021-03-22_225816](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/0/0315d2b1f0688768745d75ad1f7642e4f6b37eb8.png)

---

<div class="post-metadata">

### Author: ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)
#### Post date: [March 22, 2021, 10:07pm UTC](https://discourse.processing.org/t/make-timer-state-on-and-timer-state-off-android-to-arduino-via-bluetooth/28668/12 "2021-03-22T22:07:10Z")

</div>

@[r0x15](https://discourse.processing.org/u/r0x15)

i am same as you learning but i can help you how to communicate via Buletooth and the best for you is to make the android view the timer lcd and control the arduino sw

---

<div class="post-metadata">

### Author: ![r0x15](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@r0x15](https://discourse.processing.org/u/r0x15)
#### Post date: [March 22, 2021, 10:11pm UTC](https://discourse.processing.org/t/make-timer-state-on-and-timer-state-off-android-to-arduino-via-bluetooth/28668/13 "2021-03-22T22:11:50Z")

</div>

Tankyou !! i need learning

where do we start from ?

---

<div class="post-metadata">

### Author: ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)
#### Post date: [March 22, 2021, 10:30pm UTC](https://discourse.processing.org/t/make-timer-state-on-and-timer-state-off-android-to-arduino-via-bluetooth/28668/14 "2021-03-22T22:30:38Z")

</div>

> [@r0x15](#):
>
> Tankyou !! i need learning

read noal’s topics about arduino and BT he made very good explanation

---

<div class="post-metadata">

### Author: ![r0x15](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@r0x15](https://discourse.processing.org/u/r0x15)
#### Post date: [March 23, 2021, 11:14am UTC](https://discourse.processing.org/t/make-timer-state-on-and-timer-state-off-android-to-arduino-via-bluetooth/28668/15 "2021-03-23T11:14:52Z")

</div>

Ok  
I now i need code for timer when state on and timer when state off in form : HH:MM:SS  
where i possible set example 00:00:05 set state on  
And 00:00:10 set state off  
Visita link:[https://youtube.com/watch?v=53BYdbbe5rg&feature=share](https://youtube.com/watch?v=53BYdbbe5rg&feature=share)

---

<div class="post-metadata">

### Author: ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)
#### Post date: [March 23, 2021, 1:53pm UTC](https://discourse.processing.org/t/make-timer-state-on-and-timer-state-off-android-to-arduino-via-bluetooth/28668/16 "2021-03-23T13:53:57Z")

</div>

The Arduino is automatic does the code you want. It is easiest for you to display the result using the process sketch.

You can transfer this part of the Arduino code through Bluetooth and display the results on Android

```auto
lcd.setCursor(4,1);
if(time_h<=9){lcd.print("0");}
lcd.print(time_h);
lcd.print(":");
if(time_m<=9){lcd.print("0");}
lcd.print(time_m);
lcd.print(":");
if(time_s<=9){lcd.print("0");}
lcd.print(time_s);
lcd.print(" ");

```

---

<div class="post-metadata">

### Author: ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)
#### Post date: [March 23, 2021, 2:05pm UTC](https://discourse.processing.org/t/make-timer-state-on-and-timer-state-off-android-to-arduino-via-bluetooth/28668/17 "2021-03-23T14:05:12Z")

</div>

read this and make it when you can communicate with bluetooth then you can move to upper level

[request](https://discourse.processing.org/t/android-bluetooth-to-arduino-and-vice-versa/26578/135)

and this

> [@Android Bluetooth](https://discourse.processing.org/t/android-bluetooth/27140/2):
>
> [noel](https://discourse.processing.org/u/noel)[1](https://discourse.processing.org/t/android-bluetooth/27140#)[1h](https://discourse.processing.org/t/android-bluetooth/27140) Thank you for your interest, it seems to be a special work. I will study the code in detail and then apply it … and I will inform you of what is new Bless you

---

<div class="post-metadata">

### Author: ![r0x15](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@r0x15](https://discourse.processing.org/u/r0x15)
#### Post date: [March 23, 2021, 11:08pm UTC](https://discourse.processing.org/t/make-timer-state-on-and-timer-state-off-android-to-arduino-via-bluetooth/28668/18 "2021-03-23T23:08:43Z")

</div>

jafal  
sorry but I did not understand from the post de code of the answer and the meaning you had given me  
now I’ll try  
give me more info to be able to manage your code from arduino that I will see on android  
thank you
