// Esempio 01: accendi il led appena è premuto il pulsante
#define LED 7 // LED connected to the digital pin 7
#define BUTTON 9 // pin input button
int val = 0; // status input pin
void setup() {
pinMode(LED, OUTPUT); // pin as output
pinMode(BUTTON, INPUT); // pin as input
}
void loop() {
val = digitalRead(BUTTON); // read the pin value and save it
// control that input is HIGH (button pressed)
if (val == HIGH) {
digitalWrite(LED, HIGH); // led turn on
}
else {
digitalWrite(LED, LOW); // led turn off
}
}
um.. you are right
this is the specs of the 2N2222T i bought:
Manufacturer Part No: 2N2222A
ROHS: Yes
Current Rating: 0.8A
Voltage Rated: 40V
Transistor Type: NPN
Features: General Purpose
Package: TO-92
so if i use a resistor that limit the ampere to 0,7A it should be fine.. (altought i will lose a bit of light), or i may just use another transistor model that support 1A (as the 2SC1384)
Why is there a 10k resistor in the current return path
i corrected the resistors position
If the LED gets warm (and it will), it's forward voltage will go down --> more current --> gets even warmer ... etc
the LED will not be permanently ON, it will be installed on a replica gun to simulate the fire of the shot
i also changed the power supply of the led, now i connected it directly to the arduino 5volt