Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Ch3ri0ur/pirate_modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Ch3ri0ur committed Jun 18, 2020
2 parents 7a5fae2 + d746a5c commit a291dbe
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 32 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -102,3 +102,4 @@ dist

# TernJS port file
.tern-port
.vscode/settings.json
8 changes: 8 additions & 0 deletions .prettierrc.js
@@ -0,0 +1,8 @@
module.exports = {
semi: true,
trailingComma: 'all',
singleQuote: true,
printWidth: 120,
tabWidth: 4,
endOfLine: 'crlf',
};
61 changes: 33 additions & 28 deletions arduTalker/arduTalker.ino
Expand Up @@ -11,14 +11,16 @@

// defines variables
long duration; // variable for the duration of sound wave travel
int distance; // variable for the distance measurement
int distance; // variable for the distance measurement

void setup() {
void setup()
{
pinMode(trigPin, OUTPUT); // Sets the trigPin as an OUTPUT
pinMode(echoPin, INPUT); // Sets the echoPin as an INPUT
Serial.begin(115200); // // Serial Communication is starting with 9600 of baudrate speed
pinMode(echoPin, INPUT); // Sets the echoPin as an INPUT
Serial.begin(115200); // // Serial Communication is starting with 9600 of baudrate speed
}
void loop() {
void loop()
{
// Clears the trigPin condition
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
Expand All @@ -33,41 +35,44 @@ void loop() {
// Displays the distance on the Serial Monitor
Serial.print(distance);
Serial.print(",");
Serial.print(distance/2);
Serial.print(distance / 2);
Serial.print(",");
Serial.print(distance+5);
Serial.print(distance + 5);
Serial.print(",");
Serial.println(distance-5);
Serial.println(distance - 5);
delay(100);
char control = 0;
while(Serial.available() > 0){
while (Serial.available() > 0)
{
String input = Serial.readStringUntil('T');
Serial.println("I" + input);
if(input == "foo"){
if (input == "foo")
{
//do stuff...
}
}

if (Serial.available())
{
control = Serial.read(); //reads serial input
}
switch (control)
switch (control)
{
case '0': //moves forward
Serial.println(F("Forward"));
// reset delay time so we;re not going to stop after 2 second
break;
case '1': //left
Serial.println(F("Left"));
// reset delay time so we;re not going to stop after 2 second
break;
case '2': //right
Serial.println(F("Right"));
// reset delay time so we;re not going to stop after 2 second
break;
case '3': //backward
Serial.println(F("Backward"));
// reset delay time so we;re not going to stop after 2 second
break;
}
case '0': //moves forward
Serial.println(F("Forward"));
// reset delay time so we;re not going to stop after 2 second
break;
case '1': //left
Serial.println(F("Left"));
// reset delay time so we;re not going to stop after 2 second
break;
case '2': //right
Serial.println(F("Right"));
// reset delay time so we;re not going to stop after 2 second
break;
case '3': //backward
Serial.println(F("Backward"));
// reset delay time so we;re not going to stop after 2 second
break;
}
}
8 changes: 4 additions & 4 deletions index.js
Expand Up @@ -33,9 +33,9 @@ app.get("/stream", (req, res) => {


parser.on('data', (data) => {
if (data.startsWith("I")) {
console.log(data)
return
if (data.startsWith('I')) {
console.log(data);
return;
}
console.log(JSON.stringify(Date.now() + "," + data))
// socket.emit("measurements", Date.now() + "," + data)
Expand All @@ -57,4 +57,4 @@ app.use(cors());

const PORT = 3000;

app.listen(PORT, () => console.log(`The server is listening on port ${PORT}`));
app.listen(PORT, () => console.log(`The server is listening on port ${PORT}`));
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -4,6 +4,7 @@
"description": "serial to socketio",
"main": "index.js",
"scripts": {
"start": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
Expand Down

0 comments on commit a291dbe

Please sign in to comment.