How do you plan to solve it?
I will use my brain to think, then I will write some stuff and think some more. After a lot of thinking, writing and making dumb mispeling, I will have the answer! Of course some resources from internet :D
Used Ohms law to calculate the resistor value.
U=IR == U/I=R
Where U = voltage, I=current, R=resistance
I assume the LED is red and its forward voltage is 2.2V. (The forward voltage can be found in datasheets or by googl-ing red LED forward voltage)
To find the voltage that needs to be "restricted" to get the desired current I did the first part in (). Total voltage - voltage used to drive LED.
(5-2.2)/0.01=280 Ohm
I chose to turn on pin D2 for Arduino UNO board.
#include <avr/io.h>
#include <util/delay.h>
#define LED_PIN PORTD2
#define LED_PIN_ON() PORTD |= (1 << LED_PIN)
#define LED_PIN_OFF() PORTD &= ~(1 << LED_PIN)
void LED_PIN_INIT();
int main()
{
LED_PIN_INIT();
while (1)
{
LED_PIN_ON();
_delay_ms(400);
LED_PIN_OFF();
_delay_ms(800);
}
return 0;
}
void LED_PIN_INIT(){
DDRD |= (1 << LED_PIN);
}
You will have to believe me on this one.
Add a photo of your hardware showing the output.
Thanks for the tasks, quizzes! I will try to write code not specifically for Arduino IDE but more generically and with more register usage.
Best regards,
Rodrigo