- bitpork: Phautós tali a Balcsinál 2025 Augusztus 2 napján (szombat)
- gban: Ingyen kellene, de tegnapra
- D1Rect: Nagy "hülyétkapokazapróktól" topik
- sziku69: Fűzzük össze a szavakat :)
- Luck Dragon: Asszociációs játék. :)
- eBay-es kütyük kis pénzért
- Sub-ZeRo: Euro Truck Simulator 2 & American Truck Simulator 1 (esetleg 2 majd, ha lesz) :)
- Gurulunk, WAZE?!
- bambano: Bambanő háza tája
- Magga: PLEX: multimédia az egész lakásban
Hirdetés
Talpon vagyunk, köszönjük a sok biztatást! Ha segíteni szeretnél, boldogan ajánljuk Előfizetéseinket!
-
LOGOUT
Arduino hardverrel és szoftverrel foglakozó téma. Minden mikrovezérlő ami arduinoval programozható, és minden arduino program, board, és hardverrel kapcsolatos kérdések helye.
Új hozzászólás Aktív témák
-
Ez a példa félig működik csak jól, mert ugyan minden változásra reagál, de a számlálást ugyanúgy a loopban végzi. A számlálást be kell tenni az isr-be, akkor jó lesz.
Próbáld ezt:volatile boolean TurnDetected;
volatile boolean up;
volatile long virtualPosition=0;
const int PinCLK=2; // Used for generating interrupts using CLK signal
const int PinDT=3; // Used for reading DT signal
const int PinSW=4; // Used for the push button switch
void isr () { // Interrupt service routine is executed when any CHANGE transition is detected on CLK
volatile boolean CLK = digitalRead(PinCLK);
volatile boolean DT = digitalRead(PinDT);
up=((!CLK && DT)||(CLK && !DT));
if (up)
virtualPosition++;
else
virtualPosition--;
TurnDetected = true;
}
void setup () {
pinMode(PinCLK,INPUT);
pinMode(PinDT,INPUT);
pinMode(PinSW,INPUT);
attachInterrupt (0,isr,CHANGE); // interrupt 0 is always connected to pin 2 on Arduino UNO
Serial.begin (9600);
Serial.println("Start");
}
void loop () {
if (!digitalRead(PinSW)) { // check if pushbutton is pressed
virtualPosition=0; // if YES, then reset counter to ZERO
Serial.print ("Reset = "); // Using the word RESET instead of COUNT here to find out a buggy encoder
Serial.println (virtualPosition);
}
if (TurnDetected) { // do this only if rotation was detected
TurnDetected = false; // do NOT repeat IF loop until new rotation detected
Serial.print ("Count = ");
Serial.println (virtualPosition);
}
}
Új hozzászólás Aktív témák
- Akció! Hordozható GAMER Monitor! MSI MAG162V ! 15.6 1920x1080 FULLHD! Bolti ár fele!
- Okosóra felvásárlás!! Samsung Galaxy Watch 6, Samsung Galaxy Watch 7, Samsung Galaxy Watch Ultra
- Bomba ár! Dell Latitude 5480 - i5-6GEN I 8GB I 500GB I 14" HD I Cam I W10 I Garancia!
- Telefon felvásárlás!! Apple Watch SE/Apple Watch SE 2 (2022)
- HIBÁTLAN iPhone 15 Pro Max 256GB Black Titanium -1 ÉV GARANCIA - Kártyafüggetlen, MS3005
Állásajánlatok
Cég: FOTC
Város: Budapest