First of I am new to arduino, sorry if I am asking a simple question.
I have an LED controller for my Aquarium that sends out a PWM single 1-255 with a 5v signal. I am wanting to have a relay turn on when the signal hits 100 on one of the channels. I have a spare Arduino that I have that I was going to use the signal to control the switch.
will this work? Thanks for any help.
const int digitalin = 8;
const int relayout = 13;
const int threshold = 100;
void setup() {
pinMode(relayout, OUTPUT);
Serial.begin(9600);
}
void loop() {
int digitalValue = digitalRead(digitalin);
if (digitalValue > threshold) {
digitalWrite(relayout, HIGH);
} else {
digitalWrite(relayout, LOW);
}
Serial.println(digitalValue);
delay(1);