Shop OBEX P1 Docs P2 Docs Learn Events
Receive From HTML to Stamp — Parallax Forums

Receive From HTML to Stamp

NWCCTVNWCCTV Posts: 3,629
edited 2013-04-26 20:13 in BASIC Stamp
I have a PINK that currently I am able to communicate with my Stamp. I want to add a button on the html page that when pressed will turn on an LED on the Stamp. Can any one show me a quick and easy way to do this both on the html side and on the Stamp side?

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2013-04-26 14:22
    I don't have my old PINK stuff here with me, but I remember that I used JavaScript to create a variable and when the button was pressed it changed the variable in the PINK (referenced by tag). The update flag could be read by the BASIC Stamp and the actions taken as needed. Basically, the variables in the PINK can be accessed via JavaScript.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-04-26 14:38
    @chris, I somewhat understand what you are saying. Where I am having issues is what code I need on the Stamp side to get it all to work.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2013-04-26 16:58
    Oh, well that is a bit easier because you stay within the microcontroller language (PBASIC). There is a command to read a variable from the PINK. Once you have the variable it is easy to perform condtionals on those values. Reply this weekend if you're still having trouble and I will see if I can dig out my old code.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-04-26 17:03
    Yes, I am still having issues. I have been pulling my hair out all day on this one!!!!
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2013-04-26 18:27
    Here is an example using XMLHTTPREQUEST in javascript (nb.js) to post a zero or one into the PINK var01 variable.

    The BS2 program checks the variable and displays the ascii value (48 or 49).

    You can Google XMLHTTPREQUEST to learn about it.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-04-26 18:47
    Thanks @Ron. I will test it out. I am thinking of selling my PINK and buying a Spinnernet but if this works out I will be good for a while. Thanks again.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2013-04-26 20:13
    If you want to control an LED, comment out the GOTO MAIN line in front of the SELECT clause.

    The code in the SELECT clause sets the LED pin high or low based on the var_01 and then resets the variable so the 48 or 49 only shows briefly in the DEBUG window.
Sign In or Register to comment.