Place to put your Basic demos and examples

Moderator: Mmiscool

User avatar
By Electroguard
#44976 In the post that asked the question, I was just quoting your entry from the Weather Centre example (which is very impressive by the way) so that you would know what I was asking about. This audio module needs to connect at 9600.
And sorry about confusing things by saying "serial2print.begin 9600", that was just brain fade and finger trouble.

Here's the actual converted script, should it work?
Code: Select allserial2begin 9600
delay 500
serial2println chr(126) & chr(2) & chr(12) & chr(239) 'Reset the JQ6500
button "Play" [play]
button "Pause" [pause]
button "<" [prev]
button ">" [next]
button "Vol -" [voldown]
button "Vol +" [volup]
[loop]
wait

[play]
serial2println chr(126) & chr(2) & chr(13) & chr(239)
goto [loop]

[pause]
serial2println chr(126) & chr(2) & chr(14) & chr(239)
goto [loop]

[prev]
serial2println chr(126) & chr(2) & chr(2) & chr(239)
goto [loop]

[next]
serial2println chr(126) & chr(2) & chr(1) & chr(239)
goto [loop]

[volup]
serial2println chr(126) & chr(2) & chr(4) & chr(239)
goto [loop]

[voldown]
serial2println chr(126) & chr(2) & chr(5) & chr(239)
goto [loop]
User avatar
By viscomjim
#44977 Hi Electroguard, that certainly looks like the correct syntax for the second serial port to me. Give it a whirl and let us know if it worked for you. I also have a question concerning your code...

Why do you do the goto loop part instead of just adding the wait command to the end of each command statement, ie, you have currently...

[play]
serial2println chr(126) & chr(2) & chr(13) & chr(239)
goto [loop]

did you try this...

[play]
serial2println chr(126) & chr(2) & chr(13) & 7chr(239)
wait

Is this something that has changed in recent updates in the firmware?

Anyway, get back with your progress. Very interesting...
User avatar
By Electroguard
#44988 Thanks viscomjim, I thought the serial2 conversion syntax looked ok, but I can't get it to work so I needed to know if I was doing something wrong.

Hah, this is my very first hands-on with ESP Basic so everything is very much a part of my learning curve, and it was only a couple of days ago that I was asking questions about program flow cos I couldn't work it out for myself. The way I understood things, "wait" is for web-based events, but I needed to branch to do things that were non-webby, so didn't know how else to return from them. I'm sure I did try using "wait"s first because initially I was trying to crib from an example, but I think the script was dropping through one [branch] and into the [next] cos there was nothing webby in it for "wait" to grab. After some head-scratching I tried adding [loop] as a fixed reference to return to, and was just happy that it worked.