Place to put your Basic demos and examples

Moderator: Mmiscool

User avatar
By forlotto
#33888 oddly for me with my relay board I pull everything low to turn stuff on just how its setup.

0 is ON and 1 is OFF in my case anyways.

Even the LED on the board by itself pin2 write a zero to it toggle it off so to speak bingo it turns on.

Write a 1 to it and it will turn off ...

Mighty confusing for someone first starting off with it for days I couldn't figure out what it was that was going wrong with working with LUA I kept trying to set stuff high until one day I gave up and said I'm going to try to write a 0 to it and just see what happens well it just happened to be the pin tied to the LED so when that turned on I thought hrmmm wow I have something completely screwed up in my logic...

I always thought 1 was on state and 0 was off state but low and behold this is not true quite the oddity for me at first when I set out on a path with very little information it was a lot of brute force so to speak.

enjoy my fault I missed the previous line you typed ... Good to hear all is well though have fun testing I will tell you this will make you life 10 times easier then having to solder in connections ... I am going to be making harnesses that you just plug to both sides of the Node MCU and then just break out from there 2 15pin connectors and from there you can break out however you wish more or less for me I will only be using approx 10 pins I believe so should be relatively simplistic once I figure everything out but before I start making any harnessing etc... I need to study a bit more on the programming side of things as well.
User avatar
By Ruesselclan
#33889 I'm still a beginner re esp8266basic and microcontroller programming.

My understanding is that a pin can be used for input or output.
In case of input function an external signal can be detected/read by the pi-command.
In case of output function the 8266 actively set the pin on high or low level by the po-command.
In your example both fuctions are demonstrated and work perfectly. This can be checked via the vars-page.

But I assume that forlotto has asked for a function/command to 'read' the status of the pin in output mode. I think this make sense because otherwise it has to be parsed out of the vars page/table.

The code snippet above can not deliver that because once the mode is changed from output to input it's former output status will have been lost.

Am I wrong?

@mmiscool: Thank you for your fantastic job!
User avatar
By forlotto
#33930 Interesting you say that with LUA it was similar but I did have that working I had most everything working but had trouble trying to find a way to change SSID and PW via a web page eventually I will figure that out as well as time flows but for now being that I am stuck there I decided to give something else a try and as luck would have it Basic had that functionality ...

So now I am trying to accomplish what I have accomplished with LUA hitting a few road blocks...

mmiscool has been awesome with helping out I almost feel sorry for the guy because of my stupidity he has to answer questions that are likely silly or maybe even documented but my interpretation of the documentation sucks heck if I know maybe I'm lysdexic or something lol! But I am not understanding how to accomplish certain things although I am trying like hell every avenue I can think of based off of the documentation and examples given. I'll keep trying and keep thinking on it somehow maybe I'll figure it out brute force heh.
User avatar
By forlotto
#33931 currently I still can't just print the status of pin1 to a page lol having a whale of a time ....

I've tried it about any way I could think of.

The documentation is not clear on this reading values out to the page.

I tried like the documentation says I think I need to see a real life example of just printing the status of pin1 on page load...

tried the following
print pi 1
print pi (1)
print pi [1]
print pi {1}
print pi pin1
print pi(pin1)
print pi (pin1)
print pi [pin1]
print pi [pin1}
also tried
just like the documentation says

pi 1 p1s
if p1s = 0 then p1ss = "ON" else p1ss = OFF
wprint p1ss

also tried
pi {1} {p1s}
if p1s = 0 then p1ss = "ON" else p1ss = OFF
wprint [{p1ss}]

thinking that I had to have a dynamic value

I guess I do not understand the document as written or something...

when you say
pi {pin no} {var to place result 1/0}

it would be nice to see an example I guess to know if you me use the brackets or do not use the brackets etc...

I am slightly lost with the syntax of all of this I have your 1 example but it only applies to getting a single pin status via a url...

To me this seems kind of flaky you can write to a pin using po 1 1 this would write a 1 status to pin1 however if you try to read the status you cannot simply just type pi 1

You can print your ip like this print ip()

you cannot print the status of a pin with print pi 1 or print pi(1) ....

This makes things a bit flaky to me and hard to understand the language even though the language looks pretty dang easy at first glance it is a lot more quirky than I figured I'll keep plugging away at it eventually I'll get the pins read I want on page load.