Reset Button

A simple look at using the reset button. Code that is set in the setup function will get executed again when the reset button is pressed.

Hardware used:
  • LED
  • RGB LED
Code Used:
  • digitalWrite
  • delay

#include <Servo.h>

#define ENCODER_A 14
#define ENCODER_B 15
#define ENCODER_PORT PINC
#define SWITCH 13
#define BUTTON 12
#define RGB_RED 11
#define RGB_GREEN 10
#define RGB_BLUE 9
#define LED 6
#define SERVO 5
#define PIEZO 3
#define RELAY 2
#define POT 2
#define HALL 3
#define THERMISTOR 4
#define PHOTOCELL 5

//The setup() function runs ones at start up or when the Arduino is reset
void setup()
{
    pinMode(LED, OUTPUT); // Set the LED and RGB pins for output
    pinMode(RGB_RED, OUTPUT); 
    pinMode(RGB_GREEN, OUTPUT); 

    digitalWrite(LED, HIGH); // Light the LED fully
    delay(500); // Wait 500 milliseconds (half a second)
    digitalWrite(LED, LOW); // Turn off the the LED
}

//The loop() function runs repeatedly after setup() has run once.
void loop()
{
    // alternate between RED and GREEN
    digitalWrite(RGB_RED, HIGH); 
    digitalWrite(RGB_GREEN, LOW); 
    delay(1000); 
    digitalWrite(RGB_RED, LOW); 
    digitalWrite(RGB_GREEN, HIGH); 
    delay(1000); 
}
									

Comments are closed.