Last active
December 11, 2015 19:01
-
-
Save josejuansanchez/4f2a7814a9543dc4c159 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define PIN_ID 13 | |
| void setup() { | |
| Serial.begin(9600); | |
| pinMode(PIN_ID, OUTPUT); | |
| } | |
| void loop() { | |
| if (Serial.available() > 0) { | |
| String command = Serial.readString(); | |
| if (command == "on") { | |
| digitalWrite(PIN_ID, HIGH); | |
| } | |
| if (command == "off") { | |
| digitalWrite(PIN_ID, LOW); | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * | |
| * led_serial_button | |
| * by @josejuansanchez | |
| * | |
| */ | |
| var serial; | |
| // Start connection with arduino | |
| ui.addButton("Start", 0, 0, ui.screenWidth, 300).onClick(function() { | |
| // Connect | |
| serial = boards.connectSerial(9600, function(connected) { | |
| console.log("Connected " + connected); | |
| }); | |
| }); | |
| // Led on | |
| ui.addButton("Led on", 0, 300, ui.screenWidth, 400).onClick(function(){ | |
| serial.write("on"); | |
| }); | |
| // Led off | |
| ui.addButton("Led off", 0, 700, ui.screenWidth, 400).onClick(function(){ | |
| serial.write("off"); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * | |
| * led_serial_button | |
| * by @josejuansanchez | |
| * | |
| */ | |
| var serial; | |
| // Start connection with arduino | |
| ui.addButton("Start", 0, 0, ui.screenWidth, 300).onClick(function() { | |
| // Connect | |
| serial = boards.connectSerial(9600, function(connected) { | |
| console.log("Connected " + connected); | |
| }); | |
| }); | |
| // Led on | |
| ui.addButton("Led on", 0, 300, ui.screenWidth, 400).onClick(function(){ | |
| serial.write("on"); | |
| }); | |
| // Led off | |
| ui.addButton("Led off", 0, 700, ui.screenWidth, 400).onClick(function(){ | |
| serial.write("off"); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ui.backgroundColor(255, 255, 255); | |
| var dataLabel = ui.addText("Data: ", 10, 440, ui.screenWidth, ui.screenHeight); | |
| dataLabel.textSize(50); | |
| dataLabel.color("#000000") | |
| var serial; | |
| // Start connection with arduino | |
| ui.addButton("Connect", 0, 0, ui.screenWidth, 400).onClick(function() { | |
| serial = boards.connectSerial(9600, function(connected) { | |
| console.log("Connected: " + connected); | |
| }); | |
| // Show arduino data incoming | |
| serial.onNewData(function(data) { | |
| dataLabel.setText("Data: "+ data); | |
| console.log(data); | |
| //media.textToSpeech("tick"); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment