Hello Friends,
I'm hoping that a fresh set of eyes will see something that has stumped me for the past few hours.
I have an Arduino Micro that's being used to control a bunch of small servos. The Arduino is powered by 5v coming from a DC/DC voltage reducer which receives 12v. All the servos are powered from this 5v source and not the Arduino.
I have one pin (12) set as an output to a relay that sends 12v to another device.
The problem is that pin 12 is only outputting ~1.28v when set to HIGH. On LOW it outputs 0v.
I know the relay is working because when I jump it with 3v it switches.
My 5v pin reads 5v and my 3v pin reads 3v. My VIN pin is receiving 5v.
I've read all the topics on this that I can find and I think I have done everything right to no avail.
If I change this:
int ACrelay = 12
pinMode(ACrelay, OUTPUT);
digitalWrite(ACrelay, HIGH);
To this, there's no change.
pinMode(12, OUTPUT);
digitalWrite(12, HIGH);
Here is my sketch:
#include <Servo.h>
//Main splitter servos
Servo windscreenServo;
Servo dashServo;
Servo footwellServo;
//Secondary splitter servos
Servo cabinServo;
//AC power relay
int ACrelay = 12;
//#define ACrelay 12
//Air mode switch; "What do you want"
//Grayhill 3 position rotary switch
#define MODE_1_PIN A4
#define MODE_2_PIN A5
#define MODE_3_PIN A6
//Air direction switch; "Where do you want it"
//Grayhill 4 position rotary switch
#define DIRECTION_1_PIN A0
#define DIRECTION_2_PIN A1
#define DIRECTION_3_PIN A2
#define DIRECTION_4_PIN A3
//Fan speed; "How much do you want"
//Grayhill 4 position rotary switch
void setup() {
//Relay
pinMode(ACrelay, OUTPUT);
//Servos
windscreenServo.attach(5);
dashServo.attach(6);
footwellServo.attach(7);
cabinServo.attach(10);
//Air direction switch
pinMode(DIRECTION_1_PIN, INPUT_PULLUP);
pinMode(DIRECTION_2_PIN, INPUT_PULLUP);
pinMode(DIRECTION_3_PIN, INPUT_PULLUP);
pinMode(DIRECTION_4_PIN, INPUT_PULLUP);
//Air mode switch
pinMode(MODE_1_PIN, INPUT_PULLUP);
pinMode(MODE_2_PIN, INPUT_PULLUP);
pinMode(MODE_3_PIN, INPUT_PULLUP);
Serial.begin(9600);
}
void loop() {
//AC-Cabin-Heat Air Switch
int switch_mode_1_status = digitalRead(MODE_1_PIN);
int switch_mode_2_status = digitalRead(MODE_2_PIN);
int switch_mode_3_status = digitalRead(MODE_3_PIN);
if (switch_mode_1_status == LOW) { //AC
cabinServo.write(120); //Turn on AC and open cabin air valves to recirculate AC air
digitalWrite(ACrelay, HIGH); // Turn the AC relay on
delay(200);
Serial.println("Valve open");
} else if (switch_mode_2_status == LOW) { //Cabin air
cabinServo.write(120); //Turn off AC and open cabin air valves to recirculate ambient air
digitalWrite(ACrelay, LOW); // Turn the AC relay off
delay(200);
Serial.println("Valve open 2");
} else if (switch_mode_3_status == LOW) { //Heat
cabinServo.write(0); //Turn off AC and close cabin air valves to access heated air
digitalWrite(ACrelay, LOW); // Turn the AC relay off
delay(200);
Serial.println("Valve closed");
}
//Air Direction Switch
int switch_direction_1_status = digitalRead(DIRECTION_1_PIN);
int switch_direction_2_status = digitalRead(DIRECTION_2_PIN);
int switch_direction_3_status = digitalRead(DIRECTION_3_PIN);
int switch_direction_4_status = digitalRead(DIRECTION_4_PIN);
if (switch_direction_1_status == LOW) { //Windscreen only
Serial.println("Windscreen only");
windscreenServo.write(90); //Windscreen open
delay(200);
dashServo.write(0); //Dash closed
delay(200);
footwellServo.write(0); //Footwell closed
} else if (switch_direction_2_status == LOW) { //Windscreen and Footwell
Serial.println("Windscreen and Footwell");
windscreenServo.write(90); //Windscreen open
delay(200);
dashServo.write(0); //Dash closed
delay(200);
footwellServo.write(90); //Footwell open
} else if (switch_direction_3_status == LOW) { //Dash only
Serial.println("Dash only");
windscreenServo.write(0); //Windscreen closed
delay(200);
dashServo.write(90); //Dash open
delay(200);
footwellServo.write(0); //Footwell closed
} else if (switch_direction_4_status == LOW) { //Dash and Footwell
Serial.println("Dash and Footwell");
windscreenServo.write(0); //Windscreen closed
delay(200);
dashServo.write(90); //Dash open
delay(200);
footwellServo.write(90); //Footwell open
}
}```