Hello all!
Im trying to learn but im too impatient to bother with hello world and progress and too ignorant to understand where and how to find what im looking for..
Instead i start with what interest me and try to figure out how to make it work.
But programming has never been my strong suit, i simply fail to grasp the finer things such as data handling and why there´s a specific symbol between two identical words in the code.
But thats life, you just cant be great at everything..
However, im trying to make my arduino doing two things, turn on/off lights and display time.
that means i need to input serial commands to do different things, not merely turn something on/off or setting a predefined variable.
How can i via arduino serial monitor (and later wifi) send a specific command and a value?
I want to set the time thats displayed on a 7segment 4digit display, i would want to send a "setTime1435" through arduino serial monitor to change the current time to 14:35.
nevermind that rest of the code thats required to make 14:35 turn to 14:36 and so forth, i just really want to understand how i can define a command that i can activate remotely, pour a value into it and then use that value, or a specific part of the value later.
Another example would be my remote wallsocket program running and working, that if one inputs two numbers in serial monitor, for example 11 for socket 1, on or 10 for turn off socket one.
Its cleverly configured to allow binary 24bit to directly output binary to transmitter or 2 char input to use an array for socket on/off, but i simply cannot understand why and how its working.
code snippet:
if (mySwitch.available()) {
Serial.print(mySwitch.getReceivedBitlength());
Serial.print(" bits ");
Serial.println(mySwitch.getReceivedValue(), BIN);
mySwitch.resetAvailable();
}
if (Serial.available() > 0) {
char input = Serial.read();
if ( input == 'B' ) {
Serial.readBytesUntil('\n', binary_data, sizeof(binary_data));
Serial.print("send B");
Serial.println( binary_data );
mySwitch.send( binary_data );
} else
if ( input >= 0x30 && input <= 0x39 ) {
input = input - 0x30; // ASCII to number
serial_data[serial_pos++] = input;
} else {
Serial.print("ignore: ");
Serial.println(input, HEX);
}
Just to clarify, the above "quote" is a snippet from a working code, i need to understand what it does, why its working and how i can do it myself, for example to set correct time on the arduino clock!
And sorry for the messy and ramblish text, its half eleven in this part of the world, on a friday night no less!
So have a good night and thank you for your time and effort!