Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You don't need to create the whole page structure like in the example though. html, head and body tags are optional under certains conditions. [1]

I guess you could just write the example code like this :

  <!doctype html>
  <script src="gpio.js"></script>
  <script>
  var v = 0;
  GPIO.getPort(196).then(
    function(port) {
      setInterval(toggleLight, 1000, port);
    }
  );
  function toggleLight(port){
    v = v ? 0 : 1;
    port.write(v);
  }
  </script>
Just having the script tags would also probably works in most browsers but it wouldn't be standard compliant (if you care about it...).

[1] http://www.w3.org/TR/html-markup/



The equivalent stock Arduino demo is blink:

  void setup() {
    pinMode(13, OUTPUT);
  }

  void loop() {
    digitalWrite(13, HIGH);
    delay(1000); 
    digitalWrite(13, LOW);
    delay(1000); 
  }
From my experience of teaching many non-programmers how to use this sort of device, I think I'll stick with Arduino for now.


Just using script tags will work in every modern browser. I can't even remember how far back in IE you have to go for it not to work there.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: