arduino wait code example

Example 1: wait for time javascript

//code before the pause
setTimeout(function(){
    //do what you need here
}, 2000);

Example 2: golang sleep

package main

import (
    "fmt"
    "time"
)

func main() {
    fmt.Printf("Current Unix Time: %v\n", time.Now().Unix())

    time.Sleep(2 * time.Second)

    fmt.Printf("Current Unix Time: %v\n", time.Now().Unix())
}

Example 3: arduino keypad wait for key

//update instances and possibly fire funcitons
void loop(){
  char key1 = keypad.getKey();
  char key2 = keypad2.getKey();
 
  if (key1 != NO_KEY || key2 != NO_KEY){
    Serial.print("You pressed: ");
    Serial.print(key1 != NO_KEY ? key1 : "nothing on keypad");
    Serial.print(" and ");
    Serial.print(key2 != NO_KEY ? key2 : "nothing on keypad2");
    Serial.println(".");
  }
}

Tags:

C Example