Paul_KD7HB:
A warning! This last summer, a customer supplied a kit that contained a bag of red LEDS. From China. Some had the long-short leg polarity reversed!Paul
That happened to me.
Go by the 'flat side' as the cathode.
Paul_KD7HB:
A warning! This last summer, a customer supplied a kit that contained a bag of red LEDS. From China. Some had the long-short leg polarity reversed!Paul
That happened to me.
Go by the 'flat side' as the cathode.
If I am not mistaken, the problem lies in the LED connection. I had the same issue yesterday and got crazy over my code until i noticed the mistake in the wiring.
The LED should be connected to the PIN 9 and to GND via the resistor (if this does not solve the issue, try reversing the LED). The way you have it, both sides of the LED are HIGH at the same time so no current might flow, thus no light.
Hey thanks all for coming in
It seems my phone is too powerful and takes heavy pictures, I'll rry my best
The last photo.
Hey all, thanks a lot dor the welcome and the help, the legends are true, the arduino community really is great
Very very sorry, won´t happen again
const int LED = 9;
const int BOTAO = 7;
int val = 0;
int old_val = 0;
int state = 0;
int brightness = 128;
unsigned long startTime = 0;
void setup()
{
pinMode(LED, OUTPUT);
pinMode(BOTAO, INPUT);
}
void loop()
{
val = digitalRead(BOTAO);
if ((val==HIGH)&&(old_val==LOW)){
state= 1 - state;
startTime=millis();
delay(10);
}
if ((val ==HIGH)&&(old_val==HIGH)){
if (state==1 && (millis() - startTime)>500){
brightness++;
delay(10);
if (brightness>255){
brightness=0;
}
}
}
}
The push button resistor is wired incorrectly. The resistor should be connect between +5 volts and digital input 7. The switch contact is then connected between digital input 7 and GND.
If ithis does not work, see my earlier post #5 for how to connect the switch.
Do you want:
state= 1 - state;
or
state = !state;
Use to format your code.
Edit:
Please use code tags.
Use the </> icon in the posting menu.
[code] Paste sketch here. [/code]
Am I any closer?
Resistor between 5V and input 7, switch contact between 7 and GND
Still no reaction when I push the button
Try turning the button 90 degrees or wire it diagonally, one wire on top left, the other on bottom right, (put the black blue wire on g24).
larryd:
Do you want:
state= 1 - state;
or
state = !state;Use to format your code.
Edit:
Please use code tags.
Use the </> icon in the posting menu.[code] Paste sketch here. [/code]
The book wrote state = 1 - state
Since I am just beginning I can only copy the book, can´t analyze code yet
outsider:
Try turning the button 90 degrees or wire it diagonally, one wire on top left, the other on bottom right, (put the black wire on g24).
This is getting a bit frustrating, can´t seem to make it work still.
So, there is energy coming from the 5V, that passes through the resistor, reaches the wire connected to 7 and the button, and the ground, all connected in series, I can´t seem to understand why it won´t work.
larryd:
See S2 for switch wiring.
The image shows s2 on hole no. 6.... I am just guessing, but maybe I need to put it in 6 instead of 7?
AlvaroWang:
Resistor between 5V and input 7, switch contact between 7 and GND
An do not forget the LED between pin 9 and GND
If I tried this scheme (but putting them in spots 7 and 9 instead of what is shown) should it work? I also tried this and it won´t do anything when I hold the button
I am having a really hard time understanding why it wont work
Seems I forgot to attach it