[{'from': 'human', 'value': 'could you write the code for an arduino controller that will at the press of a button, turn on an LED, wait 3 seconds and turn it off ?'}, {'from': 'gpt', 'value': "That sounds fun; I'd be happy to! A 'blink' sketch is a common example used for learning how to program an Arduino controller, and so is using a pushbutton to control a light. Keeping an LED on for three seconds at the press of a button is a combination of the two:\n\n```c++\n/*\n  Button Blink\n\n  Turns an LED on for three seconds, then off, \n  after the press of a pushbutton attached to pin 2.\n\n  The circuit:\n  - LED attached from pin 13 to ground through 220 ohm resistor\n  - pushbutton attached to pin 2 from +5V\n  - 10K resistor attached to pin 2 from ground\n\n  Note: On most Arduinos there is already an LED on the board attached to pin 13.\n  If you want to know what pin the on-board LED is connected to on your Arduino\n  model, check the Technical Specs of your board at:\n  https://www.arduino.cc/en/Main/Products\n*/\n\n// constants won't change. They're used here to set pin numbers:\nconst int buttonPin = 2;  // the number of the pushbutton pin\nconst int ledPin = 13;    // the number of the LED pin\n\n// variables will change:\nint buttonState = 0;  // variable for reading the pushbutton status\n\n// the setup function runs once when you press reset or power the board\nvoid setup() {\n  // initialize the LED pin as an output:\n  pinMode(ledPin, OUTPUT);\n  // initialize the pushbutton pin as an input:\n  pinMode(buttonPin, INPUT);\n}\n\n// the loop function runs over and over again forever\nvoid loop() {\n  // read the state of the pushbutton value:\n  buttonState = digitalRead(buttonPin);\n\n  // check if the pushbutton is pressed. If it is, the buttonState is HIGH:\n  if (buttonState == HIGH) {\n      digitalWrite(ledPin, HIGH);  // turn the LED on (HIGH is the voltage level)\n      delay(3000);                      // wait for three seconds\n      digitalWrite(ledPin, LOW);   // turn the LED off by making the voltage LOW\n  }\n}\n```\n\nBlinking an LED according to input is a great way to test that your Arduino is working, and a good starting point for more complex projects. Getting hardware and software to work together can be difficult, so don't give up! 💡"}]