kevinshish
Member
Hi,
I have some questions about my first ever project using a Teensy. This is also my time trying to build anything really so sorry if I ask any really basic question.
I'm trying to control a fan and a solenoid valve using solid state relays and a Teensy 3.2.
Here's my code:
int relayFan = 5; //Setting the pin of the fan
int relaySol = 10 //Setting the pin of the solenoid valve
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(relaySol, OUTPUT); //Sets pin mode to output
pinMode(relayFan, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(relaySol, HIGH); //Turns solenoid on
digitalWrite(relayFan, HIGH); //Turns solenoid on
delay(5000); //Delays for 5000ms (5s)
digitalWrite(relaySol, LOW);
digitalWrite(relayFan, LOW);
delay(5000);
}
I attached a really rough circuit diagram in case my hardware setup is incorrect.
After I uploaded the code to the Teensy and plugged in the power, for some reason, the fan and solenoid stayed on constantly regardless of if the pin output was high or low. I'm extremely new to this so any help would be grreatly appreciated. Let me know if there is anything else that could be helpful.
I have some questions about my first ever project using a Teensy. This is also my time trying to build anything really so sorry if I ask any really basic question.
I'm trying to control a fan and a solenoid valve using solid state relays and a Teensy 3.2.
Here's my code:
int relayFan = 5; //Setting the pin of the fan
int relaySol = 10 //Setting the pin of the solenoid valve
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(relaySol, OUTPUT); //Sets pin mode to output
pinMode(relayFan, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(relaySol, HIGH); //Turns solenoid on
digitalWrite(relayFan, HIGH); //Turns solenoid on
delay(5000); //Delays for 5000ms (5s)
digitalWrite(relaySol, LOW);
digitalWrite(relayFan, LOW);
delay(5000);
}
I attached a really rough circuit diagram in case my hardware setup is incorrect.
After I uploaded the code to the Teensy and plugged in the power, for some reason, the fan and solenoid stayed on constantly regardless of if the pin output was high or low. I'm extremely new to this so any help would be grreatly appreciated. Let me know if there is anything else that could be helpful.