mirror of
https://github.com/2martens/uni.git
synced 2026-05-06 19:36:26 +02:00
[ES] Blatt 1 und 2 hinzugefügt
Signed-off-by: Jim Martens <github@2martens.de>
This commit is contained in:
32
es/blatt1/CMakeLists.txt
Normal file
32
es/blatt1/CMakeLists.txt
Normal file
@ -0,0 +1,32 @@
|
||||
set(ARDUINO_DEFAULT_BOARD diecimila) # Default Board ID, when not specified
|
||||
set(ARDUINO_DEFAULT_PORT /dev/ttyUSB0) # Default Port, when not specified
|
||||
|
||||
generate_arduino_firmware(uebung1-11
|
||||
SKETCH uebung1-11
|
||||
PROGRAMMER usbtinyisp
|
||||
NO_AUTOLIBS)
|
||||
|
||||
generate_arduino_firmware(uebung1-12
|
||||
SKETCH uebung1-12
|
||||
PROGRAMMER usbtinyisp
|
||||
NO_AUTOLIBS)
|
||||
|
||||
generate_arduino_firmware(uebung1-13
|
||||
SKETCH uebung1-13
|
||||
PROGRAMMER usbtinyisp
|
||||
NO_AUTOLIBS)
|
||||
|
||||
generate_arduino_firmware(uebung1-14
|
||||
SKETCH uebung1-14
|
||||
PROGRAMMER usbtinyisp
|
||||
NO_AUTOLIBS)
|
||||
|
||||
generate_arduino_firmware(uebung1-15a
|
||||
SKETCH uebung1-15a
|
||||
PROGRAMMER usbtinyisp
|
||||
NO_AUTOLIBS)
|
||||
|
||||
generate_arduino_firmware(uebung1-15b
|
||||
SKETCH uebung1-15b
|
||||
PROGRAMMER usbtinyisp
|
||||
NO_AUTOLIBS)
|
||||
15
es/blatt1/uebung1-11/uebung1-11.ino
Normal file
15
es/blatt1/uebung1-11/uebung1-11.ino
Normal file
@ -0,0 +1,15 @@
|
||||
int ledPin = 7;
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
pinMode(ledPin, OUTPUT);
|
||||
digitalWrite(ledPin, LOW);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
digitalWrite(ledPin, HIGH);
|
||||
delay(2000);
|
||||
digitalWrite(ledPin, LOW);
|
||||
delay(500);
|
||||
}
|
||||
31
es/blatt1/uebung1-12/uebung1-12.ino
Normal file
31
es/blatt1/uebung1-12/uebung1-12.ino
Normal file
@ -0,0 +1,31 @@
|
||||
int ledPin = 7;
|
||||
int buttonPin = 5;
|
||||
bool ledState = false;
|
||||
bool buttonHasBeenReset = true;
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
pinMode(ledPin, OUTPUT);
|
||||
pinMode(buttonPin, INPUT);
|
||||
digitalWrite(ledPin, LOW);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
int buttonState = digitalRead(buttonPin);
|
||||
if (buttonState == LOW && buttonHasBeenReset) {
|
||||
if (!ledState) {
|
||||
ledState = true;
|
||||
digitalWrite(ledPin, HIGH);
|
||||
}
|
||||
else {
|
||||
digitalWrite(ledPin, LOW);
|
||||
ledState = false;
|
||||
}
|
||||
buttonHasBeenReset = false;
|
||||
}
|
||||
else if (buttonState == HIGH) {
|
||||
buttonHasBeenReset = true;
|
||||
}
|
||||
delay(10);
|
||||
}
|
||||
37
es/blatt1/uebung1-13/uebung1-13.ino
Normal file
37
es/blatt1/uebung1-13/uebung1-13.ino
Normal file
@ -0,0 +1,37 @@
|
||||
int ledPin = 7;
|
||||
int buttonPin = 5;
|
||||
int buttonState;
|
||||
bool volatile ledState = true;
|
||||
bool volatile performDelay = false;
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
pinMode(ledPin, OUTPUT);
|
||||
pinMode(buttonPin, INPUT);
|
||||
attachInterrupt(buttonPin, buttonChanged, RISING);
|
||||
digitalWrite(ledPin, LOW);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
buttonState = digitalRead(buttonPin);
|
||||
if (performDelay) {
|
||||
detachInterrupt(buttonPin);
|
||||
delay(20);
|
||||
performDelay = false;
|
||||
attachInterrupt(buttonPin, buttonChanged, RISING);
|
||||
|
||||
if (buttonState == HIGH) {
|
||||
if (ledState) {
|
||||
digitalWrite(ledPin, LOW);
|
||||
} else {
|
||||
digitalWrite(ledPin, HIGH);
|
||||
}
|
||||
ledState = !ledState;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void buttonChanged() {
|
||||
performDelay = true;
|
||||
}
|
||||
20
es/blatt1/uebung1-14/uebung1-14.ino
Normal file
20
es/blatt1/uebung1-14/uebung1-14.ino
Normal file
@ -0,0 +1,20 @@
|
||||
int ledPin = 7;
|
||||
int buttonPin = 5;
|
||||
int counter = 0;
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
counter += 1;
|
||||
if (counter % 256 == 0) {
|
||||
counter = 0;
|
||||
}
|
||||
analogWrite(ledPin, counter);
|
||||
Serial.print("LED: ");
|
||||
Serial.println(counter);
|
||||
delay(50);
|
||||
}
|
||||
34
es/blatt1/uebung1-15a/uebung1-15a.ino
Normal file
34
es/blatt1/uebung1-15a/uebung1-15a.ino
Normal file
@ -0,0 +1,34 @@
|
||||
int ledPin = 7;
|
||||
int buttonPlusPin = 5;
|
||||
int buttonMinusPin = 3;
|
||||
int counter = 0;
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
pinMode(buttonPlusPin, INPUT);
|
||||
pinMode(buttonMinusPin, INPUT);
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
if (digitalRead(buttonPlusPin) == LOW) {
|
||||
counter += 1;
|
||||
}
|
||||
|
||||
if (digitalRead(buttonMinusPin) == LOW) {
|
||||
counter -= 1;
|
||||
}
|
||||
|
||||
if (counter > 255) {
|
||||
counter = 255;
|
||||
}
|
||||
if (counter < 0) {
|
||||
counter = 0;
|
||||
}
|
||||
|
||||
analogWrite(ledPin, counter);
|
||||
Serial.print("LED: ");
|
||||
Serial.println(counter);
|
||||
delay(50);
|
||||
}
|
||||
40
es/blatt1/uebung1-15b/uebung1-15b.ino
Normal file
40
es/blatt1/uebung1-15b/uebung1-15b.ino
Normal file
@ -0,0 +1,40 @@
|
||||
int ledPin = 7;
|
||||
int buttonPlusPin = 5;
|
||||
int buttonMinusPin = 3;
|
||||
int volatile counter = 0;
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
pinMode(buttonPlusPin, INPUT);
|
||||
pinMode(buttonMinusPin, INPUT);
|
||||
attachInterrupt(buttonPlusPin, increment, LOW);
|
||||
attachInterrupt(buttonMinusPin, decrement, LOW);
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
if (counter > 255) {
|
||||
counter = 255;
|
||||
}
|
||||
if (counter < 0) {
|
||||
counter = 0;
|
||||
}
|
||||
|
||||
analogWrite(ledPin, counter);
|
||||
Serial.print("LED: ");
|
||||
Serial.println(counter);
|
||||
delay(50);
|
||||
}
|
||||
|
||||
void increment() {
|
||||
counter += 1;
|
||||
delayMicroseconds(50000);
|
||||
}
|
||||
|
||||
void decrement() {
|
||||
counter -= 1;
|
||||
delayMicroseconds(50000);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user