I was looking a while ago to implement some Decimal-to-Binary conversion subroutine to be used for easy visualisation of the Registry content. Been able to see the values directly binary can help a lot when developping a driver for a IC or any piece of related software:1. Decimal-to-Binary subroutine:

 [decbin]
  i = 1
  r = 0
  binval = 0
  nr = decval
 Do
   r = nr % 2
   nr = int(nr/2)
   binval = binval + r*i
   i = i*10
 Loop while nr > 0
wait

2. Test Program:

decval = 0
binval = 0
wprint "<br><br>Decimal value "

textbox decval
button " Convert ", [decbin] 

wprint "<br><br> Binary value "
textbox binval
wprint "<br><br>"
button " Exit ", [TestExit]  
Wait

[TestExit]
end

Looking forward to see your own ideas about!

Happy breadboarding,
TJ.

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 3 – DAC

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 Extra DAC version configuration: address = 96 Read more…

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

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…