Hello, I successfully did a led to blink on my arduino. Um I am gonna upload an image and I want to know if I am doing anything wrong. It is working but I may do something wrong and burn my arduino after some days . So just give me some feedback (cool/bad) Green wire is at Ground and white at 13 pin.
I noticed that I can set HIGH or LOW to the LED. Is there anyway that I can set for example 3V or 2V ? Specific value so I will light a little at the start and after a while it will get its max value.
Also, electricity goes from pin 13 to the resistor and then passes the LED and finally goes to the GND? Or the other way arround?
You can use the PWM pins to vary the apparent brightness of the LED using analogWrite, or for extra marks you can implement software PWM on the LED on pin 13.
That confused me. If I put the resistor between cathode and GND, though the LED there will be 5V from the arduino. Right? If that happens LED will burn? According to you I am wrong...but why? I think resistor must be placed BEFORE LED so less than 4 V will come...
AWOL:
You can use the PWM pins to vary the apparent brightness of the LED using analogWrite, or for extra marks you can implement software PWM on the LED on pin 13.
Thank you. You mean that, instead of 13 PIN I will use now 11 or 10 or 9 which are PWM? and Instead of digitalWrite(led, HIGH); I will use analogWrite(led, 50) ?
I think resistor must be placed BEFORE LED so less than 4 V will come...
No it can be placed before or after.
Basically you are confused about the nature of electricity.
A circuit is just that, flowing electricity, it matters not what it flows through first, the current in a series circuit is the same at all points.
Think of current not voltage flowing.
I think resistor must be placed BEFORE LED so less than 4 V will come...
No it can be placed before or after.
Basically you are confused about the nature of electricity.
A circuit is just that, flowing electricity, it matters not what it flows through first, the current in a series circuit is the same at all points.
Think of current not voltage flowing.
indeed like Grump_Mike said you can switch both components around. Thats because you place both off your components in serie. So a part of your 5V stands over your LED and the other part stands over your resistor. Bye doing that the current through your LED is limited. If you want more explanation on that you can always ask.
If i got it right...this code should start with the led off and periodically increase the brightness. But it doesn' t. It has a specific brightness. Anyone?
int ledPin = 6;Â Â Â // LED connected to digital pin 9
int val = 0;Â Â Â Â // variable to store the read value
void setup()
{
 pinMode(ledPin, OUTPUT); // sets the pin as output
}
void loop()
{
 //val = analogRead(analogPin); // read the input pin
 if(val <= 255) {
  analogWrite(ledPin, val); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
  delay(10);
 Â
  val = val + 10;
 }else {
  val = 0;
 }
}
int ledPin = 9;Â Â Â // LED connected to digital pin 9
int val = 0;Â Â Â Â // variable to store the read value
void setup()
{
 pinMode(ledPin, OUTPUT); // sets the pin as output
}
void loop()
{
 //val = analogRead(analogPin); // read the input pin
 if(val <= 255) {
  analogWrite(ledPin, val); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
  delay(100);
  val = val + 5;
 }else {
  val = 0;
 }
}
it was too fast for my eye to see the difference. thank for your time guys. have fun.
First of all i didnt know that there is a map function. I am a programmer and I know C, Java and more quite well, so I knew the odl fashion way. Um, could i ask this map function returns random numbers between the borders? What exactly does it return? :?
Map function is used often to map an analog input having a range of 0 to 1023 to an analogWrite (PWM) output having a range of 0 to 255 such that 25% of the larger range yields 25% of the smaller range and so forth. Most often used to convert a potentiometer input to a varialble PWM to vary the intensity of a led or the speed of a motor or the similar applications. If for example you had a 0 to 10V analog output from some device, you could add a voltage devider to cut that range in half, read the value with an analog input pin and drive a PWM output pin so it tracks that voltage. The reverse is also true where the source signal is not 0 to 5V but much smaller so you amplify it with a non-inverting op amp to expand the range to 0 to 10V and now the sensor with a very small output can drive a pwm signal having a range of 0 to 255.