Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: robogrobo/Hager
base: f7eeeea296
...
head fork: robogrobo/Hager
compare: 027fb88df6
  • 7 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 38 additions and 23 deletions.
  1. +38 −23 hager_impuls.pde
View
61 hager_impuls.pde
@@ -8,19 +8,19 @@ author: dominik grob
const int ledPin = 9;
const int sensorPin = 0;
-unsigned int impuls = 0;
+long impuls = 0;
int sensorVal = 0;
int threshold = 200;
int sensorDelay = 200;
-byte ledOff = 1;
+boolean ledOff = 1;
long prevMillis = 0;
-byte debug = 0;
+boolean debug = 0;
-void setup() {
+void setup() {
pinMode(ledPin, OUTPUT);
pinMode(sensorPin, INPUT);
-
+
Serial.begin(9600);
Serial.println("Serial ready");
}
@@ -35,33 +35,48 @@ void loop() {
prevMillis = curMillis;
digitalWrite(ledPin, HIGH);
- ledOff = 0;
-
+ ledOff = false;
+
if(debug) {
- Serial.println(impuls, DEC);
+ Serial.print(impuls, DEC);
+ Serial.print("\n");
}
} else if(sensorVal < threshold) {
digitalWrite(ledPin, LOW);
- ledOff = 1;
+ ledOff = true;
}
-
+
// script commands
if(Serial.available() > 0) {
char command = Serial.read();
switch(command) {
- case 'T': // send total impuls count
- Serial.print("echo ");
- Serial.print(impuls);
- Serial.println(" | nc barbados 4919");
- break;
- case 'R': // reset impuls count
- impuls = 0;
- break;
- case 'D': // debug mode
- debug = (debug == 0) ? 1 : 0;
- break;
- default:
- return;
+ case 'S': // send total impuls count and reset
+ Serial.print("echo ");
+ Serial.print(impuls);
+ Serial.print(" | nc barbados 4919\n");
+ impuls = 0;
+ break;
+ case 'R': // reset impuls count
+ impuls = 0;
+ break;
+ case 'D': // debug mode
+ debug = !debug;
+ break;
+ case 'G': // get impuls counter
+ Serial.print("current impuls count: ");
+ Serial.print(impuls);
+ Serial.print("\n");
+ break;
+ case 'H': // help
+ Serial.print("this is the hager ec352 impuls counter help.\nbasic commandos (capital letters):\n");
+ Serial.print("s send impuls count to server\n");
+ Serial.print("r reset impuls count\n");
+ Serial.print("d toggle debug mode\n");
+ Serial.print("g get impuls count\n");
+ Serial.flush();
+ break;
+ default:
+ return;
}
}
}

No commit comments for this range

Something went wrong with that request. Please try again.