level inducator
2 posters
Page 1 of 1
level inducator
Hi,
I just want to see how a level indicator works.
The id of the indicator is "versuch" (without "").
Please write me/ insert a codeline in the folloeing sketch so it works.
Many thanks for help
JU
#define bluetooth Serial
char cmd[100];
int cmdIndex;
void exeCmd() {
//if(strcmp(cmd, "some cmd")==0) doSomething();
}
void setup() {
delay(500); // wait for BlueSMiRF to start
Serial.begin(9600);
bluetooth.begin(9600); // BlueSMiRF default baud is 115200
cmdIndex = 0;
}
void loop() {
if(bluetooth.available()) {
char c = (char)bluetooth.read();
if(c=='\n') {
cmd[cmdIndex] = 0;
exeCmd(); // execute the command
cmdIndex = 0; // reset the cmdIndex
} else {
cmd[cmdIndex] = c;
if(cmdIndex<99) cmdIndex++;
}
}
// String st= ("versuch" + "\n");
bluetooth.print("versuch 0 \n");
delay(1000);
}
I just want to see how a level indicator works.
The id of the indicator is "versuch" (without "").
Please write me/ insert a codeline in the folloeing sketch so it works.
Many thanks for help
JU
#define bluetooth Serial
char cmd[100];
int cmdIndex;
void exeCmd() {
//if(strcmp(cmd, "some cmd")==0) doSomething();
}
void setup() {
delay(500); // wait for BlueSMiRF to start
Serial.begin(9600);
bluetooth.begin(9600); // BlueSMiRF default baud is 115200
cmdIndex = 0;
}
void loop() {
if(bluetooth.available()) {
char c = (char)bluetooth.read();
if(c=='\n') {
cmd[cmdIndex] = 0;
exeCmd(); // execute the command
cmdIndex = 0; // reset the cmdIndex
} else {
cmd[cmdIndex] = c;
if(cmdIndex<99) cmdIndex++;
}
}
// String st= ("versuch" + "\n");
bluetooth.print("versuch 0 \n");
delay(1000);
}
jupi- Posts : 2
Join date : 2016-04-28
Re: level inducator
Hi, here is the code:
- Code:
char cmd[100];
int cmdIndex;
long t1=0, t2=0;
int levelIndicatorValue=0;
void exeCmd() {
//if(strcmp(cmd, "some cmd")==0) doSomething();
}
void setup() {
delay(500); // wait for BlueSMiRF to start
Serial.begin(9600); // BlueSMiRF default baud is 115200
cmdIndex = 0;
}
void loop() {
if(Serial.available()) {
char c = (char)Serial.read();
if(c=='\n') {
cmd[cmdIndex] = 0;
exeCmd(); // execute the command
cmdIndex = 0; // reset the cmdIndex
} else {
cmd[cmdIndex] = c;
if(cmdIndex<99) cmdIndex++;
}
}
t2 = millis();
if(t2 > t1+50) { // every 50 ms
t1 = t2;
Serial.print((String)"versuch " + levelIndicatorValue + "\n"); // 0 to 49
levelIndicatorValue++;
if(levelIndicatorValue==50) {
levelIndicatorValue = 0;
}
}
// DO NOT ADD DELAY HERE
// (RECEIVING COMMANDS WILL STOP WORKING)
}
Similar topics
» Using the level indicator item
» Feature for level indicators
» using level indicator to read battery charge
» Feature for level indicators
» using level indicator to read battery charge
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum