diff options
-rw-r--r-- | Drehimpulsgeber/CMakeLists.txt | 27 | ||||
-rw-r--r-- | Drehimpulsgeber/drehimp.cpp | 19 |
2 files changed, 46 insertions, 0 deletions
diff --git a/Drehimpulsgeber/CMakeLists.txt b/Drehimpulsgeber/CMakeLists.txt new file mode 100644 index 0000000..be09f29 --- /dev/null +++ b/Drehimpulsgeber/CMakeLists.txt @@ -0,0 +1,27 @@ +#=============================================================================# +# Author: QueezyTheGreat # +# Date: 26.04.2011 # +# # +# Description: Arduino CMake example # +# # +#=============================================================================# +set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules) # CMake module search path +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Arduino.cmake) # Arduino Toolchain +set(ARDUINO_LINKER_FLAGS "-lc -lm") +set(ARDUINO_SDK_PATH ${CMAKE_SOURCE_DIR}/../arduino-1.0) + +cmake_minimum_required(VERSION 2.8) +#====================================================================# +# Setup Project # +#====================================================================# +project(Drehimpusgebertest) +find_package(Arduino 1.0 REQUIRED) + +set(FIRMWARE_NAME LIFE) + +set(${FIRMWARE_NAME}_SRCS drehimp.cpp) +set(${FIRMWARE_NAME}_BOARD atmega328) +set(${FIRMWARE_NAME}_LIBS m ) +set(${FIRMWARE_NAME}_PORT /dev/ttyUSB0) + +generate_arduino_firmware(${FIRMWARE_NAME}) diff --git a/Drehimpulsgeber/drehimp.cpp b/Drehimpulsgeber/drehimp.cpp new file mode 100644 index 0000000..21011e7 --- /dev/null +++ b/Drehimpulsgeber/drehimp.cpp @@ -0,0 +1,19 @@ +volatile int cnt0 = 0; // Digitaler Pin 2 und 3 +volatile int cnt1 = 0; + +void setup() +{ attachInterrupt(0, doCount0, CHANGE); + attachInterrupt(1, doCount1, CHANGE); + Serial.begin(9600); +} + +void loop() +{ Serial.print(cnt0); + Serial.print(" - "); + Serial.println(cnt1); + delay(1000); +} + +// Dummy interrupt functions +void doCount0() { cnt0++; } +void doCount1() { cnt1++; } |