mirror of
https://github.com/2martens/uni.git
synced 2026-05-06 11:26:25 +02:00
[ES] Blatt 1 und 2 hinzugefügt
Signed-off-by: Jim Martens <github@2martens.de>
This commit is contained in:
8
es/CMakeLists.txt
Normal file
8
es/CMakeLists.txt
Normal file
@ -0,0 +1,8 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
set(CMAKE_TOOLCHAIN_FILE cmake/ArduinoToolchain.cmake)
|
||||
|
||||
Project(es C CXX)
|
||||
|
||||
add_subdirectory(blatt1)
|
||||
add_subdirectory(blatt2)
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
7
es/blatt2/CMakeLists.txt
Normal file
7
es/blatt2/CMakeLists.txt
Normal file
@ -0,0 +1,7 @@
|
||||
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(uebung2-1
|
||||
SKETCH uebung2-1
|
||||
PROGRAMMER usbtinyisp
|
||||
NO_AUTOLIBS)
|
||||
102
es/blatt2/uebung2-1/uebung2-1.ino
Normal file
102
es/blatt2/uebung2-1/uebung2-1.ino
Normal file
@ -0,0 +1,102 @@
|
||||
int ledPin = 7;
|
||||
int buttonPlusPin = 5;
|
||||
int buttonMinusPin = 3;
|
||||
int volatile counter = 0;
|
||||
int timesPressedPlus = 0;
|
||||
int timesPressedMinus = 0;
|
||||
int vergleichswert = 60;
|
||||
int rc = 10499;
|
||||
boolean increased = false;
|
||||
boolean decreased = false;
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
|
||||
pmc_set_writeprotect(false);
|
||||
pmc_enable_periph_clk(ID_TC0);
|
||||
|
||||
// Hier erfolgt die Konfiguration des Timers
|
||||
TC_Configure(TC0, 0, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_TIMER_CLOCK2) ;
|
||||
TC_SetRC(TC0, 0, rc);
|
||||
|
||||
TC0->TC_CHANNEL[0].TC_IER=TC_IER_CPCS; // IER = interrupt enable register
|
||||
TC0->TC_CHANNEL[0].TC_IDR=~TC_IER_CPCS;
|
||||
|
||||
NVIC_ClearPendingIRQ(TC0_IRQn);
|
||||
NVIC_EnableIRQ(TC0_IRQn);
|
||||
|
||||
// Hier wird der konfigurierte Timer gestartet
|
||||
TC_Start(TC0, 0);
|
||||
|
||||
// Hier werden die Taster konfiguriert
|
||||
pinMode(buttonPlusPin, INPUT);
|
||||
pinMode(buttonMinusPin, INPUT);
|
||||
|
||||
// Ausgabe über den seriellen Port
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
// Hier wird die Plus Taste abgefragt
|
||||
analogWrite(ledPin, counter);
|
||||
Serial.print("LED: ");
|
||||
Serial.println(counter);
|
||||
}
|
||||
|
||||
void increment() {
|
||||
if (counter < 255) {
|
||||
counter += 1;
|
||||
}
|
||||
}
|
||||
|
||||
void decrement() {
|
||||
if (counter > 0) {
|
||||
counter -= 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void TC0_Handler()
|
||||
{
|
||||
TC_GetStatus(TC0, 0);
|
||||
boolean tasteGedruecktPlus = (digitalRead(buttonPlusPin) == LOW);
|
||||
boolean tasteGedruecktMinus = (digitalRead(buttonMinusPin) == LOW);
|
||||
|
||||
if (tasteGedruecktPlus){
|
||||
++timesPressedPlus;
|
||||
}
|
||||
else {
|
||||
if (increased) {
|
||||
increased = false;
|
||||
}
|
||||
timesPressedPlus = 0 ;
|
||||
}
|
||||
|
||||
if (tasteGedruecktMinus){
|
||||
++timesPressedMinus;
|
||||
}
|
||||
else {
|
||||
if (decreased) {
|
||||
decreased = false;
|
||||
}
|
||||
timesPressedMinus = 0 ;
|
||||
}
|
||||
|
||||
if (timesPressedPlus >= vergleichswert) {
|
||||
if (!increased) {
|
||||
increment();
|
||||
}
|
||||
increased = true;
|
||||
timesPressedPlus = 0;
|
||||
}
|
||||
|
||||
// Hier wird die Minus Taste abgefragt
|
||||
if (timesPressedMinus >= vergleichswert) {
|
||||
if (!decreased) {
|
||||
decrement();
|
||||
}
|
||||
decreased = true;
|
||||
timesPressedMinus = 0;
|
||||
}
|
||||
}
|
||||
83
es/cmake/ArduinoToolchain.cmake
Normal file
83
es/cmake/ArduinoToolchain.cmake
Normal file
@ -0,0 +1,83 @@
|
||||
#=============================================================================#
|
||||
# Author: Tomasz Bogdal (QueezyTheGreat)
|
||||
# Home: https://github.com/queezythegreat/arduino-cmake
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#=============================================================================#
|
||||
set(CMAKE_SYSTEM_NAME Arduino)
|
||||
|
||||
set(CMAKE_C_COMPILER avr-gcc)
|
||||
set(CMAKE_CXX_COMPILER avr-g++)
|
||||
|
||||
# Add current directory to CMake Module path automatically
|
||||
if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/Platform/Arduino.cmake)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR})
|
||||
endif()
|
||||
|
||||
#=============================================================================#
|
||||
# System Paths #
|
||||
#=============================================================================#
|
||||
if(UNIX)
|
||||
include(Platform/UnixPaths)
|
||||
if(APPLE)
|
||||
list(APPEND CMAKE_SYSTEM_PREFIX_PATH ~/Applications
|
||||
/Applications
|
||||
/Developer/Applications
|
||||
/sw # Fink
|
||||
/opt/local) # MacPorts
|
||||
endif()
|
||||
elseif(WIN32)
|
||||
include(Platform/WindowsPaths)
|
||||
endif()
|
||||
|
||||
|
||||
#=============================================================================#
|
||||
# Detect Arduino SDK #
|
||||
#=============================================================================#
|
||||
if(NOT ARDUINO_SDK_PATH)
|
||||
set(ARDUINO_PATHS)
|
||||
|
||||
foreach(DETECT_VERSION_MAJOR 1)
|
||||
foreach(DETECT_VERSION_MINOR RANGE 5 0)
|
||||
list(APPEND ARDUINO_PATHS arduino-${DETECT_VERSION_MAJOR}.${DETECT_VERSION_MINOR})
|
||||
foreach(DETECT_VERSION_PATCH RANGE 3 0)
|
||||
list(APPEND ARDUINO_PATHS arduino-${DETECT_VERSION_MAJOR}.${DETECT_VERSION_MINOR}.${DETECT_VERSION_PATCH})
|
||||
endforeach()
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
foreach(VERSION RANGE 23 19)
|
||||
list(APPEND ARDUINO_PATHS arduino-00${VERSION})
|
||||
endforeach()
|
||||
|
||||
if(UNIX)
|
||||
file(GLOB SDK_PATH_HINTS /usr/share/arduino*
|
||||
/opt/local/arduino*
|
||||
/opt/arduino*
|
||||
/usr/local/share/arduino*)
|
||||
elseif(WIN32)
|
||||
set(SDK_PATH_HINTS "C:\\Program Files\\Arduino"
|
||||
"C:\\Program Files (x86)\\Arduino"
|
||||
)
|
||||
endif()
|
||||
list(SORT SDK_PATH_HINTS)
|
||||
list(REVERSE SDK_PATH_HINTS)
|
||||
endif()
|
||||
|
||||
find_path(ARDUINO_SDK_PATH
|
||||
NAMES lib/version.txt
|
||||
PATH_SUFFIXES share/arduino
|
||||
Arduino.app/Contents/Resources/Java/
|
||||
${ARDUINO_PATHS}
|
||||
HINTS ${SDK_PATH_HINTS}
|
||||
DOC "Arduino SDK path.")
|
||||
|
||||
if(ARDUINO_SDK_PATH)
|
||||
list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${ARDUINO_SDK_PATH}/hardware/tools/avr)
|
||||
list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${ARDUINO_SDK_PATH}/hardware/tools/avr/utils)
|
||||
else()
|
||||
message(FATAL_ERROR "Could not find Arduino SDK (set ARDUINO_SDK_PATH)!")
|
||||
endif()
|
||||
|
||||
2232
es/cmake/Platform/Arduino.cmake
Normal file
2232
es/cmake/Platform/Arduino.cmake
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user