Need Help With Button

Hello, I am new to working with the Arduino, and I am having trouble with coding. What I'm trying to do is make a button that you hold and when you let go after holding for at least 10 seconds, it moves on to the main part of the code. I was thinking of using a while statement, but I'm not sure. Thanks!

Welcome to the forum heyitskarl121.

Please describe what this is for. Show us what code you have so far.

heyitskarl121:
Hello, I am new to working with the Arduino, and I am having trouble with coding. What I’m trying to do is make a button that you hold and when you let go after holding for at least 10 seconds, it moves on to the main part of the code. I was thinking of using a while statement, but I’m not sure. Thanks!

try something like this …

unsigned int startTime;
unsigned int heldTime;
int buttonState;

// Connect your button to a Pin and to GND
// I selected Pin #8 
// Change the value below to the pin YOU used
#define myButton 8

Setup()
{
    // Internal Resistor will Pull-Up High when button is released
    pinMode( myButton, INPUT_PULLUP );

    // Reset the 10 second timer
    startTime = millis();
    heldTime = startTime;

    // Wait here until the Button is held for 10 consecutive seconds
    while ( heldTime - startTime < 10000 )
    {
        // Read the current state of the Button Input 
        buttonState = digitalRead( myButton );

        // Did they release button too early?
        if ( buttonState == HIGH ) 
        {
            // Sorry, we have to reset the 10 second timer
            startTime = millis();
            heldTime = startTime;
        }

        // Are they still holding the button down?        
        else
        {
            // Then keep updating the Hold Down timer
            heldTime = millis();
        }
     }

     // SUCCESS !
     // The Button was Held down for 10 consecutive seconds 
     // Now we can advance to the Main Program, the Loop()
}

Loop ()
{
    // Do fun stuff here
}

Oops! "setup()" and "loop()" should not have capital letters. Typing on an iPad?

Also you need "void" ;)

void setup() { . . . }

void loop() { . . . }