Pages: [1]   Go Down
Author Topic: Led sensor  (Read 278 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have an application that I want to read an IR sensor connected to A0. I would also like to power an IR LED from PIN 13. The problems are:
For the PIN 13 I don't want the full 5v output. Is there a way with programming to give a 2.2v level?
For A0 I want to be able to adjust the threshold to control PIN 3 to go high when the threshold is met.

Any examples of code that may help?

Thanks!
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 287
Posts: 25682
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
For the PIN 13 I don't want the full 5v output. Is there a way with programming to give a 2.2v level?
No, but you could use a simple voltage divider, but it sounds more like you just need a simple current-limiter. Can you explain why you think you need a 2.2V level?

Quote
For A0 I want to be able to adjust the threshold to control PIN 3 to go high when the threshold is met.
Code:
digitalWrite (3, analogRead(A0) >= myThreshold);
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

For the PIN 13 I don't want the full 5v output. Is there a way with programming to give a 2.2v level?
No, but you could use a simple voltage divider, but it sounds more like you just need a simple current-limiter. Can you explain why you think you need a 2.2V level?

The IR LED is 2.2V. But you suggest I do this in hardware?

digitalWrite (3, analogRead(A0) >= myThreshold);

Thanks! I'll try this!! smiley
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 287
Posts: 25682
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The IR LED is 2.2V. But you suggest I do this in hardware?
The usual way, with a current-limiting resistor.
Assume 20mA, so
5 - 2.2 / 0.02 = 140 ohm
Go for a 150 ohm, or to be really safe, a 220ohm.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Pages: [1]   Go Up
Jump to: