Inuri
Inuri

Reputation: 11

Arduino Relay control using Analog Outputs

I'm working on a project where a Mixer mixes the perfect drink for you. However I used every digital pin for sensors and now I thought I could just use the Analog Pins to control the Relays for the pumps. But since I changed the code the Pumps just dont turn off anymore. Any idea why this happens?

This is a part of my code:

#define pumpPin1 A0
#define pumpPin2 A1
#define pumpPin3 A2
#define pumpPin4 A3
//pinMode Setup for the Relay
pinMode(pumpPin1, OUTPUT);
pinMode(pumpPin2, OUTPUT);
pinMode(pumpPin3, OUTPUT);
pinMode(pumpPin4, OUTPUT);
digitalWrite(pumpPin1, LOW);
digitalWrite(pumpPin2, LOW);
digitalWrite(pumpPin3, LOW);
digitalWrite(pumpPin4, LOW);
void loop() {
  if (ts.touched()) {
    TS_Point p = ts.getPoint();
    Serial.println();
    if (p.x < 3800 && p.x > 2400 && p.y < 3100){
      Serial.print("Mische Vodka");
      digitalWrite(pumpPin1, HIGH);
      digitalWrite(pumpPin2, HIGH);
      digitalWrite(pumpPin3, HIGH);
      digitalWrite(pumpPin4, HIGH);
      delay(3000);
      digitalWrite(pumpPin1, LOW);
      digitalWrite(pumpPin2, LOW);
      digitalWrite(pumpPin3, LOW);
      digitalWrite(pumpPin4, LOW);
    }
    if (p.x < 2400 && p.y < 3100) {
      Serial.print("Mische Gin");
      digitalWrite(pumpPin1, HIGH);
      digitalWrite(pumpPin2, HIGH);
      digitalWrite(pumpPin3, HIGH);
      digitalWrite(pumpPin4, HIGH);
      delay(3000);
      digitalWrite(pumpPin1, LOW);
      digitalWrite(pumpPin2, LOW);
      digitalWrite(pumpPin3, LOW);
      digitalWrite(pumpPin4, LOW);
    }

I've already tried using analogWrite() but that didnt work either.

Upvotes: 0

Views: 46

Answers (1)

Inuri
Inuri

Reputation: 11

Update: It seems like it has nothing to do with the analog pins. I found out that the touch Display is constantly triggering the pumps. However it seems strange to me because it worked just fine with the digital pin.

Upvotes: 0

Related Questions