Cool clock on addressable diodes (part 3)

Part 3. Firmware, configuration and work algorithms

In the archive of the project, I collected the finished firmware, the libraries used, as well as an article with the original project (unfortunately, it is now not available online). In addition, there is also a scanner for the I2C bus (in case the clock module or the light sensor will use non-standard addresses).





Attention

Attention! The "MicroLED" library, written by AlexGyver, has received an update (at the time of this writing - up to version 3). However, the updated version breaks the firmware, as the algorithms for specifying the ribbon color have been changed.

The updated version adds functions that are not used in this project, and you cannot update the library without rewriting the code.





Before flashing, I recommend setting up the bluetooth module, namely, setting a name and password for it, and also checking the port baud rate.





You can leave the default settings (password 1234 or 0000), the name will also be the default.





In the process of working on this and another project, I got in my hands two bluetooth modules (which, of course, were bought from our Asian friends), the model of which was not possible to establish. In addition, they were in my hands at different times, and I could not compare them in appearance. However, the specifics of their settings were different (I believe they were HC-05 and HC-06).





So, first you need to connect the bluetooth module and arduino as follows:





Arduino





Bluetooth





Pin 2





TX





Pin 3





RX





5V





VCC





GND





GND





In some articles, there are connection schemes with resistors, but all this is superfluous. The module is configured by AT commands through the specified sketch.





Next, fill in the "BluetoothAT" sketch from the archive into arduino, open the port monitor, set the "CR&NL" carriage return settings and enter the following:





  • AT+BAUD4 ( 9600 (, )





  • AT - "". ,





    :









AT+NAME





AT+NAME?









AT+PSWD





AT+PSWD?









AT+NAME=





AT+NAMEname









AT+PSWD:"9999"





AT+PINpass





arduino bluetooth RX TX.





! bluetooth RX TX . !





, . ( ), .





"Serial Bluetooth Terminal". , "" .

"Send" "Newline" "CR" ( ). - .





, , , :





  • ;





  • ;





  • ;





  • .





, - .











#  "functions",  "LedColor()"
if (time.Hours == 13 && time.weekday != 0 && time.weekday != 6) { //
    ledColor = GREEN;
  }
  else if (time.Hours == 12 && time.minutes >= 40 ) { // 
    ledColor = LIME;
  }
      
      



, 13:00 14:00. ( ). , 20 , .

- .









else if (time.weekday != 5 && (time.Hours == (endWorkHours - 1) && time.minutes >= endWorkMinutes) || time.Hours == endWorkHours && time.minutes < endWorkMinutes) {
    ledColor = OLIVE; //  ( )
  }
      
      



( - ).

"startWorkHours" "endWorkHours" EEPROM ( ) ( Bluetooth).





, ( ) - , - , - .









info



- .





setdate



- . . - 5 . , , , ( = 0, = 1...).





settime



- . , , - 5 . , .





demo



- ( ).





check



- . ,





setworktimes



- ( ) . - 5 . , ( ). 1 .





setbright



- . , . . 5.





. , , .





( 29 31 ) , 10 .





.





:

- , ;

- , . 210 ( - 256).

- , - , 30 ( max_bright



).





, . , , , .





In conclusion, I want to add that I do not pretend to be beauty or absolute correctness of writing the code: anyone can modify it at their discretion.

It's enough for me that the clock works without freezing, changing brightness and color without freezing (in the previous version of the firmware, there were incidents, and the functions were rewritten from scratch).

Current restrictions, interruptions, and even energy saving - all of this, of course, can be implemented, only one has to ask the question: why is all this in this particular project?

It's just a watch.








All Articles