http = require('http');
fs = require('fs');
serialport = require('serialport');
port = 3000;
host = '127.0.0.1';
SerialPort = serialport.SerialPort;
arduinoPort = '/dev/ttyUSB2';
var printLog = true;
var playerRoundKills = 0;
var playerTotalKills;
var roundLive = false;
//open port
var myPort = new SerialPort(arduinoPort);
parser: serialport.parsers.raw //rohdatenparser definieren
serialport.on('open', function(){
console.log('Serial Port Opend');
serialport.on('data', function(data){
console.log(data[0]);
});
});
//implementation of abstract port functions
myPort.on('open', showPortOpen);
myPort.on('data', sendSerialData);
myPort.on('close', showPortClose);
myPort.on('error', showError);
function showPortOpen() {
console.log('port open. Data rate: ' + myPort.options.baudRate);
}
//output incoming data
function sendSerialData(data) {
console.log(data[0]);
if(typeof data[1] !== 'undefined') console.log(data[1]);
}
function showPortClose() {
console.log('port closed.');
}
function showError(error) {
console.log('Serial port error: ' + error);
}
myPort.on("open", function () {
console.log('open');
//send data (3) to arduino
myPort.write(3, function(err, results) {
if(err != null)console.log('Fehler beim ersten senden: ' + err);
if(results != null)console.log("Killcount erstmals gesendet: "+results);
});
});
http = require('http');
fs = require('fs');
serialport = require('serialport');
port = 3000;
host = '127.0.0.1';
SerialPort = serialport.SerialPort;
arduinoPort = '/dev/ttyUSB2';
var printLog = true;
var playerRoundKills = 0;
var playerTotalKills;
var roundLive = false;
//open port
var myPort = new SerialPort(arduinoPort);
parser: serialport.parsers.raw //rohdatenparser definieren
serialport.on('open', function(){
console.log('Serial Port Opend');
serialport.on('data', function(data){
console.log(data[0]);
});
});
//implementation of abstract port functions
myPort.on('open', showPortOpen);
myPort.on('data', sendSerialData);
myPort.on('close', showPortClose);
myPort.on('error', showError);
function showPortOpen() {
console.log('port open. Data rate: ' + myPort.options.baudRate);
}
//output incoming data
function sendSerialData(data) {
console.log(data[0]);
if(typeof data[1] !== 'undefined') console.log(data[1]);
}
function showPortClose() {
console.log('port closed.');
}
function showError(error) {
console.log('Serial port error: ' + error);
}
myPort.on("open", function () {
console.log('open');
//send data (3) to arduino
myPort.write(3, function(err, results) {
if(err != null)console.log('Fehler beim ersten senden: ' + err);
if(results != null)console.log("Killcount erstmals gesendet: "+results);
});
});
#include <LiquidCrystal.h>
//LDCD Display
LiquidCrystal lcd(9, 8, 6, 5, 4, 3); //Digitale Pins an dem das Display angeschlossen ist
#define LCD_WIDTH 16 //Anzahl Spalten des Display (16)
#define LCD_HEIGHT 2 //Anzahl Zeilen des Display (2)
#define DEBUG_MODE true
void setup(void)
{
Serial.begin(9600);
byte i;
lcd.begin(LCD_WIDTH, LCD_HEIGHT,1);
lcd.setCursor(0,0);
}
void loop() {
// when characters arrive over the serial port...
if (Serial.available()) {
//clear display for new killcount
//lcd.clear();
// wait a bit for the entire message to arrive
delay(100);
// read all the available characters
while (Serial.available() > 0) {
// write each character to display as ascii
int temp = Serial.read();
lcd.write(temp);
Serial.println(temp);
}
//Serial.flush();
}
}
#include <LiquidCrystal.h>
//LDCD Display
LiquidCrystal lcd(9, 8, 6, 5, 4, 3); //Digitale Pins an dem das Display angeschlossen ist
#define LCD_WIDTH 16 //Anzahl Spalten des Display (16)
#define LCD_HEIGHT 2 //Anzahl Zeilen des Display (2)
#define DEBUG_MODE true
void setup(void)
{
Serial.begin(9600);
byte i;
lcd.begin(LCD_WIDTH, LCD_HEIGHT,1);
lcd.setCursor(0,0);
}
void loop() {
// when characters arrive over the serial port...
if (Serial.available()) {
//clear display for new killcount
//lcd.clear();
// wait a bit for the entire message to arrive
delay(100);
// read all the available characters
while (Serial.available() > 0) {
// write each character to display as ascii
int temp = Serial.read();
lcd.write(temp);
Serial.println(temp);
}
//Serial.flush();
}
}