# Lumen Light Control

**URL:** <https://discuss.bluerobotics.com/t/lumen-light-control/819>\
**Category:** Lights\
**Created:** [March 7, 2017, 1:57am UTC](https://discuss.bluerobotics.com/t/lumen-light-control/819 "2017-03-07T01:57:39Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![elmho01](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@elmho01](https://discuss.bluerobotics.com/u/elmho01)\
**Post date:** [March 7, 2017, 1:57am UTC](https://discuss.bluerobotics.com/t/lumen-light-control/819/1 "2017-03-07T01:57:39Z")

</div>

I have tried to control the lumen sub sea light with the code you have provided but however have trouble doing so. I was able to make the light turn on it’s own however, I was wondering if there is a way to control light by flipping a switch running through an arduino.

Thank You In Adavnce

---

<div class="post-metadata">

**Author:** ![rjehangir](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/rjehangir/32/671_2.png) [@rjehangir](https://discuss.bluerobotics.com/u/rjehangir)\
**Post date:** [March 7, 2017, 4:05am UTC](https://discuss.bluerobotics.com/t/lumen-light-control/819/2 "2017-03-07T04:05:54Z")

</div>

Hi Ahmed,

The _Lumen_ light is controlled by a PWM signal that can be generated with the Arduino Servo library. Can you please post the code you have tried as well as a picture of your wiring setup? That will help us figure this out quickly!

Rusty

---

<div class="post-metadata">

**Author:** ![tciii](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/tciii/32/673_2.png) [@tciii](https://discuss.bluerobotics.com/u/tciii)\
**Post date:** [March 7, 2017, 1:26pm UTC](https://discuss.bluerobotics.com/t/lumen-light-control/819/3 "2017-03-07T13:26:02Z")

</div>

@elmho01,  
Do you have a common ground between the power supply for the Lumen and the Arduino? The Arduino cannot control the light if there is no common ground.  
Regards,  
TCIII AVD

---

<div class="post-metadata">

**Author:** ![elmho01](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@elmho01](https://discuss.bluerobotics.com/u/elmho01)\
**Post date:** [March 7, 2017, 9:34pm UTC](https://discuss.bluerobotics.com/t/lumen-light-control/819/4 "2017-03-07T21:34:18Z")

</div>

Thank you that did help, but now it remains on constantly.

---

<div class="post-metadata">

**Author:** ![elmho01](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@elmho01](https://discuss.bluerobotics.com/u/elmho01)\
**Post date:** [March 7, 2017, 9:40pm UTC](https://discuss.bluerobotics.com/t/lumen-light-control/819/5 "2017-03-07T21:40:17Z")

</div>

Lumen Positive —\> 12V Battery +  
Lumen Negative ----\> 12V Ground  
Lumen Data —\> PWM 9  
Switch Positive —\> 5V Arduino  
Switch Data —\> PWM 7

I can’t upload my code any suggestions

---

<div class="post-metadata">

**Author:** ![jwalser](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/jwalser/32/2234_2.png) [@jwalser](https://discuss.bluerobotics.com/u/jwalser)\
**Post date:** [March 7, 2017, 9:53pm UTC](https://discuss.bluerobotics.com/t/lumen-light-control/819/6 "2017-03-07T21:53:45Z")

</div>

You can use this website to get a link to pasted code [http://pastebin.com/](http://pastebin.com/)

---

<div class="post-metadata">

**Author:** ![elmho01](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@elmho01](https://discuss.bluerobotics.com/u/elmho01)\
**Post date:** [March 7, 2017, 10:26pm UTC](https://discuss.bluerobotics.com/t/lumen-light-control/819/7 "2017-03-07T22:26:06Z")

</div>

> **[Lumen Light Test - Pastebin.com](https://pastebin.com/nx64n3BU)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

---

<div class="post-metadata">

**Author:** ![jwalser](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/jwalser/32/2234_2.png) [@jwalser](https://discuss.bluerobotics.com/u/jwalser)\
**Post date:** [March 7, 2017, 10:31pm UTC](https://discuss.bluerobotics.com/t/lumen-light-control/819/8 "2017-03-07T22:31:55Z")

</div>

You have some _syntax errors_ in your code, which will allow your code to compile and run without any warnings, but may not produce the results you expect.

> if (buttonS = HIGH)

To make a logical comparison, use `if (buttonS == HIGH)`. You should look up the difference.

> else (buttonS = LOW);

Same thing here, and the semicolon following the else statement has some important implications, too. Note that you probably don’t want to be making a logical comparison here. I suggest you search the Internet for examples of ‘if-then-else’ statements in c or c++, you can even look for Arduino-specific examples.

-Jacob

---

<div class="post-metadata">

**Author:** ![elmho01](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@elmho01](https://discuss.bluerobotics.com/u/elmho01)\
**Post date:** [March 8, 2017, 12:38am UTC](https://discuss.bluerobotics.com/t/lumen-light-control/819/9 "2017-03-08T00:38:41Z")

</div>

So should they be replaced with values like 0 or 1?

---

<div class="post-metadata">

**Author:** ![rjehangir](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/rjehangir/32/671_2.png) [@rjehangir](https://discuss.bluerobotics.com/u/rjehangir)\
**Post date:** [March 8, 2017, 12:50am UTC](https://discuss.bluerobotics.com/t/lumen-light-control/819/10 "2017-03-08T00:50:35Z")

</div>

Hi @elmho01,

Comparison statements must use the `==` symbol. So:

```auto
if (buttonS == HIGH)

```

---

<div class="post-metadata">

**Author:** ![jwalser](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/jwalser/32/2234_2.png) [@jwalser](https://discuss.bluerobotics.com/u/jwalser)\
**Post date:** [March 8, 2017, 12:51am UTC](https://discuss.bluerobotics.com/t/lumen-light-control/819/11 "2017-03-08T00:51:33Z")

</div>

You should revise the decision portion of your loop() code to look something like this:

```auto
if (buttonS == HIGH) {
    do something;
} else {
    do something else;
}

```

---

<div class="post-metadata">

**Author:** ![elmho01](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@elmho01](https://discuss.bluerobotics.com/u/elmho01)\
**Post date:** [March 8, 2017, 12:51am UTC](https://discuss.bluerobotics.com/t/lumen-light-control/819/12 "2017-03-08T00:51:38Z")

</div>

I realize that but i’m still confused. I tried replacing it with 0 and 1 but it seems like the charge isn’t dischargng.So no matter whether it is on or off, it remains on.

> **[Lumen Light Test - Pastebin.com](https://pastebin.com/TLJYnRdh)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

And removing the semicolon next to the else causes an error.

---

<div class="post-metadata">

**Author:** ![rjehangir](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/rjehangir/32/671_2.png) [@rjehangir](https://discuss.bluerobotics.com/u/rjehangir)\
**Post date:** [March 8, 2017, 3:24pm UTC](https://discuss.bluerobotics.com/t/lumen-light-control/819/13 "2017-03-08T15:24:57Z")

</div>

Ahmed,

The semicolon next to the else statement is invalid because if you want to specify a condition like `else (buttonS == 0); {`, then you need to use `else if` so that it becomes `else if (buttonS == 0); {`. The way you have it, the else statement code will never execute.

-Rusty

---

<div class="post-metadata">

**Author:** ![jwalser](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/jwalser/32/2234_2.png) [@jwalser](https://discuss.bluerobotics.com/u/jwalser)\
**Post date:** [March 8, 2017, 3:57pm UTC](https://discuss.bluerobotics.com/t/lumen-light-control/819/14 "2017-03-08T15:57:35Z")

</div>

Putting the semicolon after the comparison is equivalent to putting an empty statement after the condition. If the condition is true, the next statement is executed. Putting multiple expressions inside of curly braces `{ }` causes those expressions to be interpreted as a single statement.

Here is an example:

```auto
#include <stdio.h>

int main() {
        int x = 1;

        if (x > 0) {
                printf("hello\n");
        } else if (x < 0); {
                printf("goodbye\n");
        }
}

```

Outputs:

```auto
hello
goodbye

```

The above program is equivalent to:

```auto
#include <stdio.h>

int main() {
        int x = 1;

        if (x > 0) {
                printf("hello\n");
        } else if (x < 0) {
                ; 
        }
        printf("goodbye\n");
}

```

What the program should be in order to get the output you would expect:

```auto
#include <stdio.h>

int main() {
        int x = 1;

        if (x > 0) {
                printf("hello\n");
        } else if (x < 0) { // <- NO SEMICOLON
                printf("goodbye\n");
        }
}

```

---

<div class="post-metadata">

**Author:** ![elmho01](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@elmho01](https://discuss.bluerobotics.com/u/elmho01)\
**Post date:** [March 8, 2017, 8:04pm UTC](https://discuss.bluerobotics.com/t/lumen-light-control/819/15 "2017-03-08T20:04:31Z")

</div>

That makes sense let me try that.  
Because else means otherwise, but you can’t give else an assignment line

---

<div class="post-metadata">

**Author:** ![elmho01](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@elmho01](https://discuss.bluerobotics.com/u/elmho01)\
**Post date:** [March 8, 2017, 8:50pm UTC](https://discuss.bluerobotics.com/t/lumen-light-control/819/16 "2017-03-08T20:50:44Z")

</div>

Thank you guys so much for your help, with a little modification it is finally working.
