Datasheet

NOT WORKING? (3 things to try)
MAKING IT BETTER
CODE (no need to type everything in just click)
MORE, MORE, MORE:
Light Not Fading
A bit of a silly mistake we
constantly made, when you
switch from simple on off to
fading remember to move the
LED wire from pin 13 to pin 9.
21
CIRC-07
File > Examples > 2.Digital > Button
(example from the great arduino.cc site, check it out for other great ideas)
/*
* Button
* by DojoDave <http://www.0j0.org>
*
* Turns on and off a light emitting diode(LED) connected to digital
* pin 13, when pressing a pushbutton attached to pin 7.
* http://www.arduino.cc/en/Tutorial/Button
*/
int ledPin = 13; // choose the pin for the LED
int inputPin = 2; // choose the input pin (for a pushbutton)
int val = 0; // variable for reading the pin status
void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inputPin, INPUT); // declare pushbutton as input
}
void loop(){
val = digitalRead(inputPin); // read input value
if (val == HIGH) { // check if the input is HIGH
digitalWrite(ledPin, LOW); // turn LED OFF
} else {
digitalWrite(ledPin, HIGH); // turn LED ON
}
}
More details, where to buy more parts, where to ask more questions:
http://ardx.org/CIRC07
Light Not Turning On
The pushbutton is square
and because of this it is easy
to put it in the wrong way.
Give it a 90 degree twist and
see if it starts working.
On button off button: Fading up and down:
The initial example may be a little underwhelming (ie. I Lets use the buttons to control an analog signal. To do this
don't really need an Arduino to do this), let’s make it a you will need to change the wire connecting the LED from pin
little more complicated. One button will turn the LED on 13 to pin 9, also change this in code.
int ledPin = 13; ----> int ledPin = 9;
the other will turn the LED off. Change the code to:
Next change the loop() code to read.
int ledPin = 13; // choose the pin for the LED
int inputPin1 = 3; // button 1
int value = 0;
int inputPin2 = 2; // button 2
void loop(){
if (digitalRead(inputPin1) == LOW) { value--; }
void setup() {
else if (digitalRead(inputPin2) == LOW) { value++; }
pinMode(ledPin, OUTPUT); // declare LED as output
value = constrain(value, 0, 255);
pinMode(inputPin1, INPUT); // make button 1 an input
analogWrite(ledPin, value);
pinMode(inputPin2, INPUT); // make button 2 an input
delay(10);
}
}
void loop(){
Changing fade speed:
if (digitalRead(inputPin1) == LOW) {
digitalWrite(ledPin, LOW); // turn LED OFF
If you would like the LED to fade faster or slower, there is only
} else if (digitalRead(inputPin2) == LOW) {
digitalWrite(ledPin, HIGH); // turn LED ON
one line of code that needs changing;
}
delay(10); ----> delay(new #);
}
To fade faster make the number smaller, slower requires a
Upload the program to your board, and start toggling the
larger number.
LED on and off.
Underwhelmed?
No worries these circuits are all
super stripped down to make
playing with the components
easy, but once you throw them
together the sky is the limit.