1
0
Fork 0
This repository has been archived on 2019-12-23. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
arduinisten/arduino/sketch_oct13b/applet/sketch_oct13b.cpp
2010-03-30 18:55:18 +02:00

63 lines
977 B
C++

#include "WProgram.h"
void setup();
void loop();
int pinA = 11;
int pinB = 12;
int pinLED = 13;
void setup() {
Serial.begin(9600);
pinMode(pinA, INPUT);
digitalWrite(pinA, HIGH);
pinMode(pinB, INPUT);
digitalWrite(pinB, HIGH);
pinMode(pinLED, OUTPUT);
}
int a_old, b_old, dreh;
void loop() {
// shall we blink
// if (millis() - prevMillis > 100) {
// prevMillis = millis();
//
// if (pinLEDstate == LOW)
// pinLEDstate = HIGH;
// else
// pinLEDstate = LOW;
// digitalWrite(pinLED, pinLEDstate);
//
int a = digitalRead(pinA);
int b = digitalRead(pinB);
if (a != a_old || b != b_old) {
Serial.print(digitalRead(pinA));
Serial.print(" ");
Serial.print(digitalRead(pinB));
Serial.println();
dreh++;
// Serial.println("C:> _");
}
digitalWrite(pinLED, a);
a_old = a;
b_old = b;
}
int main(void)
{
init();
setup();
for (;;)
loop();
return 0;
}