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

[ES] Added 4.1

Signed-off-by: Jim Martens <github@2martens.de>
This commit is contained in:
2015-05-19 16:11:33 +02:00
parent cfc5de6692
commit 97f1d61d61

View File

@ -0,0 +1,44 @@
// these variables describe the used hardware pins
// adjust them when you use other pins
// hardware pins
int ledPin = 13;
int analogLevel = 0;
/**
* Setup function for initial setup code
*/
void setup() {
// Configure pins
analogWrite(ledPin, 0);
// initialize serial port
Serial.begin(9600);
Serial2.begin(9600);
}
/**
* Loop function for main code
*/
void loop() {
if (Serial2.available() > 0) {
char command = Serial2.read();
if (command == '1') {
for (int i = 0; i < 255; i++) {
analogLevel += 1;
analogWrite(ledPin, analogLevel);
Serial.print("LED-Level: ");
Serial.println(analogLevel);
delay(19);
}
Serial2.print('1');
for (int i = 255; i > 0; i--) {
analogLevel -= 1;
analogWrite(ledPin, analogLevel);
Serial.print("LED-Level: ");
Serial.println(analogLevel);
delay(19);
}
Serial2.print('2');
}
}
}