Skip to content

Commit e3c5c50

Browse files
authored
Update Usage.md
1 parent 3730d79 commit e3c5c50

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

extras/docs/Usage.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,5 +229,49 @@ Control blinking by digit. This function controls the blinking property of one d
229229
The following Sketch uses Serial1 as display port, displays counts from 0-999 in both decimal and hexdecimal format and a float point number starting form 1.23 increased by 0.01 each step. The display changed every second.
230230

231231
```c
232+
#include <UART_7Seg_Display.h>
232233

234+
#define LED_SERIAL Serial1 // By default this code uses Serial1 as LED display port
235+
// If you are using Arduino with only 1 Serial (such as UNO), you may want to disable
236+
// the above line and use the following setting:
237+
// #include <SoftwareSerial.h>
238+
// #define LED_SERIAL swSerial
239+
// SoftwareSerial swSerial(11, 12); // creating SoftwareSerial instance, using pin 11 as Rx, 12 as Tx (Rx not used in this example)
240+
241+
UART_7Seg_Display Disp(LED_SERIAL); // creating display driver instance
242+
243+
244+
uint16_t cnt=0;
245+
float x=1.23;
246+
247+
void setup()
248+
{
249+
Serial.begin(115200); // Initializing printing serial port
250+
LED_SERIAL.begin(9600); // Initializing LED display serial port
251+
Disp.clear(); // Clear any display contents
252+
}
253+
254+
void loop()
255+
{
256+
Serial.print("Disaplying in decimal : ");
257+
Serial.println(cnt, DEC);
258+
Disp.displayDec(cnt, 0, 3); // Display cnt as decimal number on DIG0-DIG2 (3 digits wide)
259+
delay(1000);
260+
Serial.print("Disaplying in hexdecimal : ");
261+
Serial.println(cnt, HEX);
262+
Disp.displayHex(cnt, 0, 4); // Display cnt as hexdecimal on DIG0-DIG3 (4 digits wide)
263+
delay(1000);
264+
Serial.print("Disaplying in float : ");
265+
Serial.println(x,2);
266+
Disp.displayFloat(x, 0, 3, 2); // Display x as float number on DIG0-DIG2, 2 digits after decimal point
267+
Disp.sendCmd(SEG_ON, 0x17); // Turn on the decimal point on DIG2 (segment address 0x17, see datasheets)
268+
delay(1000);
269+
Disp.sendCmd(SEG_OFF, 0x17); // Turn off the decimal point on DIG2
270+
cnt = cnt + 1;
271+
if (cnt == 1000)
272+
{
273+
cnt = 0;
274+
}
275+
x = x+0.01;
276+
}
233277
```

0 commit comments

Comments
 (0)