Lesson 5 - Digital Inputs, De-bounce, Interrupts and Deep Sleep

Поделиться
HTML-код
  • Опубликовано: 26 окт 2024

Комментарии • 19

  • @danielpeach8560
    @danielpeach8560 4 года назад +2

    I just want to say, your audio is FINE :) Here on RUclips, we are used to trying to listen through fans blowing on the mic, people shoving the mic halfway down their throat when they talk, construction in the background... a slight pitch change is no issue at all. Thanks again for the great videos and explanations!

  • @aniceprintingperson188
    @aniceprintingperson188 3 года назад +1

    i get an error saying ledpin was not declared in this scope... what have i missed?
    EDIT: found my problem, didn't use a capitol "P" in "ledPin" when i was inputting my global variables! Yay to learning and finding mistakes yourself!!
    Ty for the vids, so far very helpful Ricardo

  • @peterlution
    @peterlution 3 года назад

    Great video. Thanks! I have followed along and got almost everything done, except one - The deep sleep button does not work as designed. Clicking on the button cannot wake up the system. The watch dog runs fine but the button interrupt only works when it is not in sleep mode. Do you know why? I am using MEGA 2560 instead of UNO.

  • @MikeNewham
    @MikeNewham 5 лет назад

    Great piece of code.. Would appreciate if you could use this in future videos & get temperature / humidity etc while outputting same to an OLED - then go back to sleep. Cheers!

    • @rickmorenojr
      @rickmorenojr  5 лет назад +1

      You should check out Lesson 19 - DS3231 RTC Module for temperature, or Lesson 12 - DHT11 Temperature and Humidity Sensor. There are other temperature and humidity sensors out there that are better than the dht11.

  • @rickmorenojr
    @rickmorenojr  6 лет назад +1

    Technically, setting the pinMode parameter to OUTPUT sets the pin LOW.

    • @bgable7707
      @bgable7707 4 года назад

      I saw that Kevin in his code did not explicitly set this to LOW. So, that makes since, however, do you have a reference to this documentation?

  • @emberleona9278
    @emberleona9278 6 лет назад

    Some of those other videos Like lesson 1 are hard to find. Can you explain using a mosfet to control latches? Vs. a transitor. Im not to sure of the difference just told I could use that for 5v usb power triggering. for my vibrochat idea

  • @nuke1548
    @nuke1548 3 года назад

    When I am trying to upload the code from the IDE i get and error saying "debounce was not declared in this scope". any ideas on what is going on?

  • @Minzkraut
    @Minzkraut 6 лет назад

    Can you provide a link for those neat pre-cut wires? These standard jumper wires are so messy :(

    • @rickmorenojr
      @rickmorenojr  6 лет назад +1

      Sure - Elenco 350 Piece Pre-formed Jumper Wire Kit amzn.to/2z6sCCw

  • @joelrendon7886
    @joelrendon7886 2 года назад

    where can i get the code tanks.

  • @juicyjproductions2886
    @juicyjproductions2886 4 года назад +1

    How can I fix the error “serialOut” was not declared in this scope. I checked and all the code is the same.

    • @jjm5780
      @jjm5780 4 года назад

      I was also getting this error. I just copied and pasted the code that was provided in GitHub.
      github.com/rmorenojr/ElegooTutorial/blob/master/Lesson%205%20-%20Digital%20Inputs/DigitalInput_Debounce/DigitalInput_Debounce.ino

    • @juicyjproductions2886
      @juicyjproductions2886 4 года назад

      Jj M Thanks

  • @rkc5026
    @rkc5026 3 года назад +1

    Does anyone know the difference in wiring diagram at 2:40?

  • @Hambxne
    @Hambxne 3 года назад

    // here is the code
    const int ledPin = 5;
    const int buttonPin = 2;
    boolean lastButton = HIGH;
    boolean currentButton = HIGH;
    boolean ledOn = false;
    int counter = 0;
    void setup(){
    Serial.begin(9600);
    pinMode(ledPin, OUTPUT);
    pinMode(buttonPin, INPUT_PULLUP);
    serialOut(ledOn, counter);
    }
    void loop(){
    currentButton = debounce(lastButton);
    if(lastButton == LOW && currentButton == HIGH){
    counter += 1;
    ledOn = !ledOn;
    digitalWrite(ledPin, ledOn);
    serialOut(ledOn, counter);
    }
    lastButton = currentButton;
    }
    boolean debounce(boolean last){
    boolean current = digitalRead(buttonPin);
    if(last != current){
    delay(5);
    current = digitalRead(buttonPin);
    }
    return current;
    }
    void serialOut(boolean ledState, int i){
    Serial.print("LED is ");
    if (ledState) Serial.print("ON - button pressed ");
    if (!ledState) Serial.print("OFF - button pressed ");
    Serial.print(i);
    Serial.println(" times");
    }