Zum Inhalt springen

Schulprojekt

Schlagwörter: 

  • Dieses Thema hat 18 Antworten und 2 Teilnehmer, und wurde zuletzt aktualisiert vor 2 Wochen, 3 Tage von Abhishek Prabhakar.
Ansicht von 15 Beiträgen - 1 bis 15 (von insgesamt 19)
  • Autor
    Beiträge
  • #6613 Antworten
    Zerspaner
    Teilnehmer

    Hallo,

    ich möchte eine Encoder ECW1J-B24-BC0024L an einen Arduino UNO anschließen. welche Pins nehmen ich da?

    ich habe den Tx->1 und 2 genommen und folgendes Programm erstellt. Mithilfe des Internets.

    int messungPin1 = LOW;
    int messungPin1Alt = LOW;
    int encoderWert = 0;
    
     void setup() { 
     pinMode(2, INPUT);
     Serial.begin(9600);
     } 
    
     void loop() {
     messungPin1 = digitalRead(2);
     if ((messungPin1 == HIGH) && (messungPin1Alt == LOW)) {
     encoderWert++;
     Serial.println (encoderWert);
     }
     messungPin1Alt = messungPin1;
     }

    Es will einfach nicht funktionieren.

    Der Mittler Anschluss meines encoders ist in 5V
    Die Aüßernen Tx->1 und 2

    #6614 Antworten
    Stefan Hermann
    Administrator

    Hallo Zerspaner,

    vielen Dank für deine Frage. Ich hab mir den Code mal angesehen. Im Grunde gehst du das Thema schon richtig an. Du hast nur einen von den beiden Pins nicht als Input deklariert. Passiert mir auch immer wieder. Dann braucht der Encoder Pull-Up-Widerstände. Du kannst die internen vom Arduino nutzen. Anstelle von pinMode(pin,INPUT) schreibt man dann einfach pinMode(pin, INPUT_PULLUP). Ich empfehle auch, Pin 0 und 1 vom Arduino-Board nicht zu verwenden. Die werden für die Datenübertragung zum Computer verwendet und können ziemlich unvorhersehbares Verhalten zeigen. Hier der Code:

    int encoder0PinA = 3;
    int encoder0PinB = 4;
    
    int messungPin1 = LOW;
    int messungPin1Alt = LOW;
    
    int encoderWert = 0;
    
    void setup() {
      pinMode(encoder0PinA, INPUT_PULLUP);
      pinMode(encoder0PinB, INPUT_PULLUP);
      Serial.begin(115200);
    }
    
    void loop() {
      messungPin1 = digitalRead(encoder0PinA);
      if ((messungPin1 == HIGH) && (messungPin1Alt == LOW)) {
        if (digitalRead(encoder0PinB) == LOW) {
          encoderWert--;
        } else {
          encoderWert++;
        }
        Serial.println(encoderWert);
      }
      messungPin1Alt = messungPin1;
    }

    BTW: Dieses Verfahren ist nicht sehr präzise und das Arduino muss die ganze Zeit »zuhören«, was das Programm langsam macht. Wenn dich das stört, gibt es Programm-Bibliotheken, die da Abhilfe schaffen oder du nutzt die Interrupts des Arduinos. Ich hab hier mal was rüber geschrieben: Arduino-Encoder

    Ich hoffe, das hilft dir schon mal weiterhilft :)

    Liebe Grüße

    #6620 Antworten
    Stefan Hermann
    Administrator

    Ach so: Die Schaltung geht jetzt vom GND in den mittleren Anschluss des Encoders, die äußeren Anschlüsse sind mit den Arduino-Pins 3 und 4 verbunden.

    #19345 Antworten
    specialmussel
    Gast

    If the file has been modified from its original state trap the cat, some details such as the timestamp may not fully reflect those of the original file.

    #28045 Antworten
    five nights at freddy’s
    Gast

    In addition to the details provided here, I’ll also introduce you online. This is a very nice list of the games I’ve played, which includes some of my all-time favorites and most well-known titles. another subject. Different games that I bet you’ll like.

    #28522 Antworten
    lalisa leee
    Gast

    I am extremely intrigued in this subject. Even though I have read numerous articles, I believe yours is the best.
    papa’s freezeria

    #28629 Antworten
    io games free
    Gast

    This piece will tell you more about what’s going on. I want to find out more about that here

    #28630 Antworten
    willsaldana
    Gast

    A lot of the blogs I see these days don’t really have anything I’m interested in, but this one definitely does io games free

    #28692 Antworten
    lisakim
    Gast

    That’s amazing! They’re exactly what I was looking for! I thank you all for sharing these wonderful and satisfying experiences with me! Now let’s go with family and friends. wordle unlimited

    #28784 Antworten
    Cozy
    Gast

    WhatsApp mods are third-party applications that offer enhanced features and customization options beyond the official WhatsApp. These mods often include themes, privacy controls, advanced media sharing, and other tweaks, providing users with a more personalized and feature-rich messaging experience. However, users should exercise caution and prioritize security when using such mods.

    #28832 Antworten
    Tensay
    Gast

    [url=https://www.curezone.biz/forums/fm.asp?i=2458414]gfme pawer[/url]

    #28833 Antworten
    Tensay
    Gast

    zcx

    #29211 Antworten
    Gabriela
    Gast

    Experience the epitome of sophisticated living with our carefully curated apartments for rent in Matn . These residences seamlessly blend modern design with functionality, offering a luxurious yet comfortable lifestyle. Immerse yourself in the serene ambiance of Matn, where each apartment becomes a haven tailored to your contemporary preferences.

    #29420 Antworten
    jasima
    Gast

    A lot of the blogs I see these days don’t really have anything I’m interested in, but this one definitely does

    Visit mbwhatsking.

    #31110 Antworten
    Raleigh Kozey
    Gast

    Thank you for providing such useful information. I’ve been having trouble coming up with many questions about this topic. I’ll stick with you! wordle hint

Ansicht von 15 Beiträgen - 1 bis 15 (von insgesamt 19)
Antwort auf: Antwort #6620 in Schulprojekt
Deine Information: