Multiple digitalWrite via dashboard

For Arduino users on XOBXOB
Posts: 1
Joined: Sun Sep 15, 2013 12:58 am

Multiple digitalWrite via dashboard

Postby Thearm » Mon Sep 16, 2013 5:04 pm

I’m still a novice so may have missed obvious info. Is there a way to control multiple off / on switches, ie blink 2 or more LEDs on the same sketch?

If not, is it a planned feature to set up toggles for each pin from the dashboard?

Or, should I approach that using a response to text input, for instance
“red” to digitalWrite (8, HIGH),
“green” digitalWrite (7, HIGH) etc.

Posts: 18
Joined: Sat Jul 27, 2013 8:41 am

Re: Multiple digitalWrite via dashboard

Postby xobxob » Tue Sep 17, 2013 6:18 am

Blinking multiple LEDs is possible.

First you have to set all the LED pins you want to use as OUTPUT in the Setup part of your sketch. e.g.:

pin_blink2 = 9;
pinMode (pin_blink2, OUTPUT);

Then, assuming want to control the second LED separately from the first one, you can add a second message using the New button next to the XOB name on the Advanced dashboard. For example, call the second LED message, switch2. Then, when the XOB contents response returns, you can get the value of "switch2" and set the LED appropriately. e.g.:

String LED = XOB.getMessage("switch2");
if (LED == "\"ON\"") {
digitalWrite (pin_blink2, HIGH);
} else {
digitalWrite (pin_blink2, LOW);

Return to “Arduino”

Who is online

Users browsing this forum: No registered users and 1 guest