Topic: How to manipulate an on-screen LED on the Android?
I have three LEDs defined on my Android RemoteXY GUI. How do I manipulate them from my Arduino program?
Is there a manual for RemoteXY somewhere?
You are not logged in. Please login or register.
RemoteXY community → Need help → How to manipulate an on-screen LED on the Android?
I have three LEDs defined on my Android RemoteXY GUI. How do I manipulate them from my Arduino program?
Is there a manual for RemoteXY somewhere?
I have three LEDs defined on my Android RemoteXY GUI. How do I manipulate them from my Arduino program?
Is there a manual for RemoteXY somewhere?
For each LED, there are up to 3 values to be set (you configure whether you want R, G, and B when you create the LED object).
Simply set vales for R, G, and B brightness in your sketch.
My RGB control project using 3 sliders should give you a start....
http://remotexy.com/en/editor/8273ea1b5 … 342216057/
/*
-- LED Strip Controller --
This source code of graphical user interface
has been generated automatically by RemoteXY editor.
To compile this code using RemoteXY library 2.3.3 or later version
download by link http://remotexy.com/en/library/
To connect using RemoteXY mobile app by link http://remotexy.com/en/download/
- for ANDROID 4.1.1 or later version;
- for iOS 1.2.1 or later version;
This source code is free software; you can REDistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
*/
#include <EEPROM.h> // used for saving settings
//////////////////////////////////////////////
// RemoteXY include library //
//////////////////////////////////////////////
// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__HARDSERIAL
#include <RemoteXY.h>
// RemoteXY connection settings
#define REMOTEXY_SERIAL Serial
#define REMOTEXY_SERIAL_SPEED 115200
// RemoteXY configurate
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
{ 255,4,0,3,0,46,0,8,26,0,
1,2,64,50,21,8,24,31,83,97,
118,101,0,4,128,1,19,98,10,134,
134,4,128,1,32,98,10,204,204,4,
128,1,6,98,10,1,1,65,15,17,
49,21,10 };
// this structure defines all the variables of your control interface
struct {
// input variable
uint8_t save_button; // =1 if button pressed, else =0
int8_t GRN; // =0..100 slider position
int8_t BLU; // =0..100 slider position
int8_t RED; // =0..100 slider position
// output variable
uint8_t RGB_led_r; // =0..255 LED Red brightness
uint8_t RGB_led_g; // =0..255 LED Green brightness
uint8_t RGB_led_b; // =0..255 LED Blue brightness
// other variable
uint8_t connect_flag; // =1 if wire connected, else =0
} RemoteXY;
#pragma pack(pop)
/////////////////////////////////////////////
// END RemoteXY include //
/////////////////////////////////////////////
// EEPROM Addresses
#define SETTINGS_ID "LED STRIP V5"
#define SETTINGS_ADDRESS 64
// Arduino Pins
// PWM Outputs
const byte pin_RED = 11; // RED Channel (PWM)
const byte pin_GRN = 10; // GRN Channel (PWM)
const byte pin_BLU = 9; // BLU Channel (PWM)
// Define the settings udt
typedef struct udt_Settings {
uint8_t RED; // 0 to 255
uint8_t GRN; // 0 to 255
uint8_t BLU; // 0 to 255
char id[19]; // this is last to catch structure changes
};
//Create the settings data of type udt_Settings
udt_Settings settings;
// other variables
uint8_t RED_PWM_Max = 100;
uint8_t GRN_PWM_Max = 100;
uint8_t BLU_PWM_Max = 100;
#ifdef REMOTEXY_MODE__SOFTSERIAL
SoftwareSerial mySerial = SoftwareSerial(REMOTEXY_SERIAL_RX,REMOTEXY_SERIAL_TX);
#endif
// **********************************************************************
void setup() {
RemoteXY_Init ();
pinMode (pin_RED, OUTPUT);
pinMode (pin_GRN, OUTPUT);
pinMode (pin_BLU, OUTPUT);
// connect to the serial port
#ifdef REMOTEXY_MODE__SOFTSERIAL
mySerial.begin(REMOTEXY_SERIAL_SPEED);
#endif
#ifndef REMOTEXY_MODE__SOFTSERIAL
Serial.begin(REMOTEXY_SERIAL_SPEED);
#endif
// retrieve settings from EEPROM
EEPROM.get(SETTINGS_ADDRESS, settings);
// initialise start-up settings if not present
if (strcmp(settings.id, SETTINGS_ID) != 0) {
settings.RED = RED_PWM_Max/2; // half brightness
settings.GRN = GRN_PWM_Max/2; // half brightness
settings.BLU = BLU_PWM_Max/2; // half brightness
strcpy(settings.id, SETTINGS_ID);
EEPROM.put(SETTINGS_ADDRESS, settings);
}
RemoteXY.RED = settings.RED;
RemoteXY.GRN = settings.GRN;
RemoteXY.BLU = settings.BLU;
} // end setup
// ***********************************************************************
// LOOP
// ***********************************************************************
void loop() {
RemoteXY_Handler ();
// PWM Control
// OMG this is so simple it's untrue
// Read the slider positions, and control the RGB ouputs
// such a shame the sliders are 0-100, but the RGB values are 0-255
// which is why we need to "map" them
analogWrite(pin_RED, map(RemoteXY.RED, 0, 100, 0, RED_PWM_Max));
analogWrite(pin_GRN, map(RemoteXY.GRN, 0, 100, 0, GRN_PWM_Max));
analogWrite(pin_BLU, map(RemoteXY.BLU, 0, 100, 0, BLU_PWM_Max));
// Show the colour mix on the mobile device display
RemoteXY.RGB_led_r = map(RemoteXY.RED, 0, 100, 0, 255);
RemoteXY.RGB_led_g = map(RemoteXY.GRN, 0, 100, 0, 255);
RemoteXY.RGB_led_b = map(RemoteXY.BLU, 0, 100, 0, 255);
// respond to the Save button if pressed
if (RemoteXY.save_button) {
RemoteXY.save_button = 0;
// turn the LEDs off for visual indication of "saving"
analogWrite(pin_RED,0);
analogWrite(pin_GRN,0);
analogWrite(pin_BLU,0);
settings.RED = RemoteXY.RED;
settings.GRN = RemoteXY.GRN;
settings.BLU = RemoteXY.BLU;
EEPROM.put(SETTINGS_ADDRESS, settings);
delay(750);
} // if (RemoteXY.save_button)
} // void(loop)
Thank you! That was very nice! This has helped me a great deal...
RemoteXY community → Need help → How to manipulate an on-screen LED on the Android?
Powered by PunBB, supported by Informer Technologies, Inc.