1
0
mirror of https://github.com/2martens/uni.git synced 2026-05-06 11:26:25 +02:00

[ES] Blatt 3 fertiggestellt

Signed-off-by: Jim Martens <github@2martens.de>
This commit is contained in:
2015-06-09 17:10:11 +02:00
parent 04805ce189
commit 8999977fc5
4 changed files with 177 additions and 186 deletions

View File

@ -24,31 +24,7 @@ bool volatile ccwMaxReached = false;
bool volatile lightLED = false;
bool volatile read_ready = false;
/**
* Calculates the servo position.
*
* @param int currentServoPos
* @param int rotationZ
*/
int calculate_new_servo_pos(int currentServoPos, int rotationZ) {
int newServoPos = currentServoPos + rotationZ;
if (newServoPos > 159) {
newServoPos = 159;
cwMaxReached = true;
lightLED = true;
}
if (newServoPos < 25) {
newServoPos = 25;
ccwMaxReached = true;
lightLED = true;
}
return newServoPos;
}
/**
* Setup function for initial setup code
@ -88,25 +64,17 @@ void setup() {
*/
void loop() {
if (Serial.available() > 0) {
char command[8];
char currentChar;
int i = 0;
bool readable = true;
while (readable) {
currentChar = Serial.read();
readable = (currentChar != -1);
command[i] = currentChar;
i++;
}
command[i] = '\0';
String command;
command = Serial.readString();
String ledOn = "LED_on";
String ledOff = "LED_off";
if (strcmp(command, "LED_on") == 0) {
if (command == ledOn) {
digitalWrite(ledPin, HIGH);
}
else {
else if (command == ledOff) {
digitalWrite(ledPin, LOW);
}
Serial.println(command);
}
}