roggesound
Member
Hey. I made a quick thing in the office today that turns on an LED when a light sensor goes high, turns on another LED when another light sensor goes high, and turns on a relay when both light sensors go high.
The board is a Teensy LC. The sensors are ALSPT19 Light sensors from Adafruit (adafru.it/2748). The LEDs are 5v LEDs with built in resistors for pinball machines.
The issue is, the LEDs are not getting the full 3.3v. The relay gets 3.3v when activated. The LEDs get between 1.5 and 1v. They also seem to change brightness based on whether they're both on or not.
Here's my code. Everything is working as expected except for the brightness/voltage issues. Let me know what you think.
LEDs are "doorA" and "doorB", relay is "StpLght".
The board is a Teensy LC. The sensors are ALSPT19 Light sensors from Adafruit (adafru.it/2748). The LEDs are 5v LEDs with built in resistors for pinball machines.
The issue is, the LEDs are not getting the full 3.3v. The relay gets 3.3v when activated. The LEDs get between 1.5 and 1v. They also seem to change brightness based on whether they're both on or not.
Here's my code. Everything is working as expected except for the brightness/voltage issues. Let me know what you think.
LEDs are "doorA" and "doorB", relay is "StpLght".
Code:
const int sensorA = A0;
const int sensorB = A1;
const int doorA = 12;
const int doorB = 11;
const int StpLght = 10;
void setup() {
Serial.begin(9600);
pinMode(sensorA, INPUT);
pinMode(sensorB, INPUT);
pinMode(doorA, OUTPUT);
pinMode(doorB, OUTPUT);
pinMode(StpLght, OUTPUT);
}
void loop() {
if (analogRead(sensorA) >= 25){
digitalWrite(doorA, HIGH);
}
if (analogRead(sensorB) >= 25){
digitalWrite(doorB, HIGH);
}
if (analogRead(sensorA) >= 25 && analogRead(sensorB) >= 25){
digitalWrite(StpLght, HIGH);
}
else {
digitalWrite(doorA, LOW);
digitalWrite(doorB, LOW);
digitalWrite(StpLght, LOW);
}
}