Tilt Switch Activated LED's

Introduction: Tilt Switch Activated LED's

Good Afternoon Here is my very first Arduino Code that i wrote, just completed it now.Fritzing: http://fritzing.org/projects/tilt-sw...d-leds-arduino Tilt Switch or Button Activated LED's

Turns on and off a light emitting diode(LED) connected to digital pin 13 and 12, when activating the Tilt Switch or a pushbutton attached to pin 2. When the tilt switch gives the Arduino the Off Signal, LED12 Will Switch off and LED13 will turn on.

---How To Connect your switch to Digital pin 2

LED1 to Digital Pin13 and LED2 to Digital Pin12

Connect the switch Via a 100K Resistor to the 5V Pin on the Arduino

Connect Led ground to any ground on the Arduino board

The circuit: * LED attached from pin 13 to ground * LED attached from pin 12 to ground * pushbutton attached to pin 2 from +5V * 10K resistor attached to pin 2 (switch/button) from ground

Note: on most Arduinos there is already an LED on the board attached to pin 13.

Turns on and off a light emitting diode(LED) connected to digital pin 13 and 12, when activating the Tilt Switch or a pushbutton attached to pin 2. When the tilt switch gives the Arduino the Off Signal, LED12 Will Switch off and LED13 will turn on.

The circuit: * LED attached from pin 13 to ground * LED attached from pin 12 to ground * pushbutton attached to pin 2 from +5V * 10K resistor attached to pin 2 (switch/button) from ground

* Note: on most Arduinos there is already an LED on the board attached to pin 13.

Tested by Ryner and Eesa 2013-12-31 This example code is in the public domain.

http://www.arduino.cc/en/Tutorial/Button */

// constants won't change. They're used here to // set pin numbers: const int buttonPin = 2; // the number of the pushbutton pin const int ledPin12 = 12; // the number of the 1st LED pin const int ledPin13 = 13; // the number of the 2nd LED pin