In the process of working on a new Driver Tutorial for the ESPBasic Series I am looking today to implement some Decimal-to-BCD and BCD-to-Decimal subroutines.

What I have done so far:

1. BCD-to-Decimal subroutine:

hv = val >> 4
hl = val and 15
val = hv*10 + hl

2. Decimal-to-BCD subroutine:

d = int( val / 10 )
d1 = d * 10
d2 = val - d1
val = d*16 + d2

3. Test Program

let val = 96
textbox val
button "To DEC", [DEC]
button "To BCD", [BCD]
wprint "<br><br>"
button " Exit ", [TestExit] 


If you have any other idea please feel free to share it, looking forward to see smarter solutions that that. I’m sure they are!

Happy breadboarding,

Categories: ESPBasic

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

AC Dimmer

AC Dimmer DevBoard – MPDMv7.5 – Part 2

For a more detailed description please take a look at the Part 1: MPDMv7.5 AC Dimmer devboard overview MPDMv7.5 AC Dimmer devboard ESP Basic program example for the basic version configuration: 'write("starttimer",10) cls 'VCNT GPIO Read more…


ESPBasic – Web Interface – CSS elements example

A quick example on how to change your Web interface GUI objects properties without using a separate CSS file: Reading Humidity and Temperature from a DHT22 Sesor connected to the GPIO5 and also retrieving Date Read more…


ESPBasic Series: Web Interface Slider demo

How easy or complicated is in ESPBasic to have a instant response slider for your MPDMv4 AC Dimmer Web interface? Just look at the code below: cls let xpv = 0 let PWMpin = 5 Read more…