move stuff
This commit is contained in:
parent
cc49225717
commit
3f524bc360
6 changed files with 0 additions and 0 deletions
|
@ -1,65 +0,0 @@
|
|||
#include <avr/interrupt.h>
|
||||
#include <avr/io.h>
|
||||
|
||||
|
||||
int pinA = 11;
|
||||
int pinB = 12;
|
||||
int ledPin = 13;
|
||||
|
||||
void setup() {
|
||||
//Timer2 Settings
|
||||
TCCR2A = 0;
|
||||
TCCR2B = 0<<CS22 | 1<<CS21 | 0<<CS20;
|
||||
|
||||
//Timer2 Overflow Interrupt Enable
|
||||
TIMSK2 = 1<<TOIE2;
|
||||
|
||||
// pullups
|
||||
digitalWrite(pinA, HIGH);
|
||||
digitalWrite(pinB, HIGH);
|
||||
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
volatile int8_t enc_delta; // -128 ... 127
|
||||
static int8_t last;
|
||||
|
||||
|
||||
ISR(TIMER2_OVF_vect) {
|
||||
int8_t neu, diff;
|
||||
|
||||
// convert gray to binary
|
||||
neu = 0;
|
||||
if(digitalRead(pinA))
|
||||
neu = 3;
|
||||
if(digitalRead(pinB))
|
||||
neu ^= 1;
|
||||
|
||||
diff = last - neu; // difference last - new
|
||||
if( diff & 1 ) { // bit 0 = value (1)
|
||||
last = neu; // store new as next last
|
||||
enc_delta += (diff & 2) - 1; // bit 1 = direction (+/-)
|
||||
}
|
||||
}
|
||||
|
||||
int8_t val_alt;
|
||||
void loop() {
|
||||
int8_t val;
|
||||
|
||||
digitalWrite(13,HIGH);
|
||||
|
||||
cli();
|
||||
val = enc_delta;
|
||||
// enc_delta = val & 1;
|
||||
sei();
|
||||
|
||||
if (val != val_alt) {
|
||||
Serial.println(val>>1);
|
||||
}
|
||||
|
||||
val_alt = val;
|
||||
|
||||
delay(100);
|
||||
digitalWrite(13,LOW);
|
||||
delay(100);
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
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;
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
#include <LCD4Bit.h>
|
||||
LCD4Bit lcd = LCD4Bit(2);
|
||||
|
||||
void setup() {
|
||||
lcd.init();
|
||||
lcd.clear();
|
||||
lcd.printIn("World Arduinination in progress...");
|
||||
}
|
||||
|
||||
int i = 0,j = 0, dir = 1;
|
||||
char bfr[4];
|
||||
|
||||
void loop() {
|
||||
digitalWrite(13, HIGH);
|
||||
|
||||
lcd.cursorTo(2, 0);
|
||||
itoa(i, bfr, 10);
|
||||
lcd.printIn(bfr);
|
||||
lcd.printIn("%");
|
||||
|
||||
lcd.cursorTo(2, 4);
|
||||
|
||||
for(j=0; j < (i / 3); j++)
|
||||
lcd.print(255);
|
||||
for(j=i/3; j < 100/3; j++)
|
||||
lcd.printIn(" ");
|
||||
|
||||
|
||||
if(i >= 98)
|
||||
dir = -1;
|
||||
if(dir == -1 && i <= 80)
|
||||
dir = 1;
|
||||
|
||||
i += dir;
|
||||
|
||||
digitalWrite(13,LOW);
|
||||
delay(100);
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
#include <LCD4Bit.h>
|
||||
LCD4Bit lcd = LCD4Bit(2);
|
||||
|
||||
void setup() {
|
||||
lcd.init();
|
||||
lcd.clear();
|
||||
|
||||
// create char
|
||||
lcd.commandWrite(0x40);
|
||||
lcd.print(0b10001);
|
||||
lcd.print(0b01010);
|
||||
lcd.print(0b10101);
|
||||
lcd.print(0b11111);
|
||||
lcd.print(0b01110);
|
||||
lcd.print(0b10001);
|
||||
lcd.print(0b10001);
|
||||
lcd.print(0b01010);
|
||||
|
||||
// back to normal
|
||||
lcd.cursorTo(1,0);
|
||||
for(uint8_t i = 0; i < 80; i++) {
|
||||
lcd.print(0x00+(i&0x7));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
digitalWrite(13, HIGH);
|
||||
|
||||
lcd.commandWrite(0x40+8*random(8));
|
||||
uint8_t fnord = random(8);
|
||||
for (uint8_t i = 0; i<8; i++) {
|
||||
if(i == fnord) {
|
||||
lcd.print(0b11111);
|
||||
} else {
|
||||
lcd.print(0b00000);
|
||||
}
|
||||
}
|
||||
|
||||
digitalWrite(13,LOW);
|
||||
delay(10);
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
int ledPin = 11;
|
||||
int foo = 0;
|
||||
int dir = 1;
|
||||
|
||||
int loga[32] = {0, 1, 2, 2, 2, 3, 3, 4, 5, 6, 7, 8, 10, 11,
|
||||
13, 16, 19, 23, 27, 32, 38, 45, 54, 64, 76,
|
||||
91, 108, 128, 152, 181, 215, 255};
|
||||
|
||||
|
||||
void setup() {
|
||||
pinMode(ledPin, OUTPUT);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
analogWrite(ledPin, loga[foo]);
|
||||
delay(100);
|
||||
|
||||
foo += dir;
|
||||
if (foo >= 31) {
|
||||
dir = -1;
|
||||
}
|
||||
|
||||
if (foo <= 0) {
|
||||
dir = +1;
|
||||
}
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
int pinA = 7;
|
||||
int pinB = 8;
|
||||
int pinLED = 13;
|
||||
int pinLEDstate = LOW;
|
||||
long prevMillis = 0;
|
||||
|
||||
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:> _");
|
||||
} else {
|
||||
if (dreh%2 == 0) {
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
|
||||
digitalWrite(pinLED, a);
|
||||
a_old = a; b_old = b;
|
||||
}
|
Reference in a new issue