This file contains 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
## How it was with Serial | |
if(not commands.empty()): | |
command=commands.get() | |
if(args.verbosity>0): | |
print("DISPATCHER: sending to Arduino: "+command) | |
start=time.time() | |
arduino.write(command) | |
# wait until we get OK back |
This file contains 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
// How it was with Serial: | |
// *** Receive *** | |
byteCount = -1; | |
byteCount = Serial.readBytesUntil('\n',buffer,bSize); | |
if (byteCount > 0) { // Really simple parsing | |
strcpy(command,strtok(buffer,",")); | |
This file contains 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
/251/ { print "LED, 0,", ($2=="UP") ? "0" : "1" } | |
/250/ { print "LED, 1,", ($2=="UP") ? "0" : "1" } |
This file contains 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
var mqtt = require('sc-mqtt'); | |
var client = mqtt.client(); // local host is default. Otherwise use host, user/pwd | |
client.connect(); | |
//Subscribe to changes in the state of the Arduino | |
client.subscribe('/arduino/1/status'); | |
var player; // To remember who pulled the switch | |
// Here we tell Minecraft to give us control after certain events | |
events.on('player.PlayerInteractEvent', function (listener, event) { |
This file contains 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
//Her gir vi beskjed om å kalle en funksjon når visse hendelser skjer i Minecraft | |
events.on('player.PlayerInteractEvent', function (listener, event) { | |
// Vi må finne ut om det var en "Lever" (altså en spak) som ble trukket i. Nå gjelder det ALLE spaker :-) | |
// Du kan hente ut spakens posisjon vha. block.location om du vil se etter en spesiell | |
var block = event.getClickedBlock(); | |
var type = block.getType(); | |
if(type==org.bukkit.Material.LEVER) { | |
if (block.data==3){ | |
writeStatus('commands.txt','DOWN'); |
This file contains 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
tail -f commands.txt > /dev/cu.usbserial-A702MUZO |
This file contains 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
#include <LiquidCrystal.h> | |
LiquidCrystal lcd(12,11,5,4,3,2); | |
char commandbuffer[100]; | |
int readserial() | |
{ | |
int i=0; |