-->
Page 1 of 2

Basic bit and I/O examples

PostPosted: Wed Jul 27, 2016 3:41 pm
by Ecoli-557
Greeting All!
I have been making great advances in this interpreter, but, coming from a background where I had slower clocks, not nearly the string handling stuff, the math functions are awesome, and all of the GUI screen stuff let alone the WEB stuff - Awesome!!

However, I need some examples of very basic functions such as comparing a pin to either high or low, how to assign a variable to a bit in a byte variable, any aliasing a variable to a pin, etc.

I have worked with the higher level functions and now I need to turn my attention to these lower functions so I can get a better idea how this thing actually works.

I will attach external single bit things to this chip, sense their status, send them out either wifi (so cool), serial or some other thing.

Any examples would be great!

Re: Basic bit and I/O examples

PostPosted: Wed Jul 27, 2016 6:55 pm
by Mmiscool
to get the status of a pin you can use the io() function.

Code: Select allbla = io(pi,d3)


or to check the pins state and run code based on it.

Code: Select allif io(pi,d3) = 1 then print "high" else print "low"

There is no mapping a pin to a variable. It is all controlled in the IO() function.

Re: Basic bit and I/O examples

PostPosted: Wed Jul 27, 2016 7:20 pm
by Ecoli-557
OK, thanks for the clarification.
We don't have anything like:
Flags, which would be classed as a byte variable.
And, relay=flags.0 which would be a single bit flag which is bit 0 of the byte 'Flags'.
It would be convienant.

Is there no way (or need) to declare a var as a bit, byte, word, or double-word?

Thanks for all you do,
Regards.

Re: Basic bit and I/O examples

PostPosted: Wed Jul 27, 2016 7:23 pm
by Mmiscool
Only have 2 variable types in esp basic. Strings and numbers. Numbers are floating point.