Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 0:66e658666f89
- Child:
- 1:53649f3053fc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Jan 15 08:49:39 2022 +0000 @@ -0,0 +1,33 @@ +#include "mbed.h" + +Serial nextion(p28, p27); +DigitalOut myled1(LED2); +DigitalOut myled2(LED4); + +char buffer[20]; +int znak = 0; + +void Rx_interrupt(void){ + char c; + if(nextion.readable()) { + c = nextion.getc(); + buffer[znak] = c; + znak++; + if ((znak >= 3) && (buffer[znak-1] == 0xff) && (buffer[znak-2] == 0xff) && (buffer[znak-3] == 0xff)) { + nextion.printf("\n\r"); + if (buffer[2] == 0x04){ + myled1 = buffer[3]; + }else if (buffer[0] == 0x5A){ + myled2 = buffer[1] - 48; + } + memset(buffer,0,strlen(buffer)); + znak = 0; + } + } +} + +int main(){ + nextion.attach(&Rx_interrupt, Serial::RxIrq); + while (1) { + } +} \ No newline at end of file