Hi everyone,
I'm brand new to the forum- and to Arduino. I've been working on a project to add an RF volume control to a an old amplifier. I've been trhying to do it all myself- but I'm now stuck on a problem that seems to be above my pay grade- so I was hoping someone might be able to spot what I'm doing wrong and offer some advice...
So here goes:
Circuit components:
-
Arduino Nano
(I had an Arduino Nano but I accidentally destroyed it by connecting it to USB power while it was connected to raw power, so I'm using a clone from a local store temporarily. I've ordered a new original.) -
L293D motor driver:
https://www.banggood.com/5Pcs-MINI-L293D-Arduino-Motor-Drive-Expansion-Board-Mini-L293D-Motor-Drive-Module-p-1269354.html?rmmds=buy&cur_warehouse=CN
CommunityOfRobots.com is for sale | HugeDomains -
315Mhz Simple RF Rciever
Simple RF M4 Receiver - 315MHz Momentary Type : ID 1096 : $4.95 : Adafruit Industries, Unique & fun DIY electronics and kits -
Alps Motorised Potentiometer: (4.5v nominal)
https://www.alps.com/prod/info/E/HTML/Potentiometer/RotaryPotentiometers/RMP_RK16/RK16812MG099.html
The circuit is very simple- a 5v high signal on either channel (pins 8 & 9) should trigger the L293D driver to command the motor forward or backward. When no signal is received the motor should be stationary. The whole circuit runs on 5VDC and shares the same power supply.
The problem I'm having is that once connected the motor driver is constantly outputting 2.2v in either direction, depending on the polarity of the IN1 and IN2 pins. That signal seems to be coming from pin 4- I measured the output with my cheap oscilloscope and it seems to be switching 4v on and off every 16ms.... it exists whether or not the RF module is connected and I'm guessing this is the source of the problem.
So I'm wondering if anyone can give me any tips on how to correct it? I've been searching for an answer for days and it's driving me crazy!
Any help would be very much appreciated.
Kind regards,
Zap
PS I've also attached a photo is the small switch bounce I get from the RF module- I'm not sure if that's significant.
Code:
// Connection pins:
int in1 = 4; // IN1
int in2 = 5; // IN2
int volup = 8; // 5v volume up signal from receiver
int voldn = 9; // 5v volume down signal from receiver
void setup()
{
Serial.begin(9600);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(volup, INPUT);
pinMode (voldn, INPUT);
}
void loop()
{
int voluphigh = digitalRead(volup); // Volume up reading
int voldnhigh = digitalRead(voldn); // volume down reading
digitalWrite(in1, 1); // set speed of motor to high
digitalWrite(in2, 1); // set rotation direction of motor (1 or 0)
while (digitalRead(9) == LOW && digitalRead(10) == LOW && digitalRead(11) == LOW && digitalRead(12) == LOW) {
digitalWrite(in1, 0); // set motor to off
digitalWrite(in2, 0); // set rotation direction of motor (1 or 0); // Loops until button is pressed
}
while (digitalRead(9) == HIGH) { // Volume up pressed
digitalWrite(in1, 1); // set speed of motor to high
digitalWrite(in2, 0); // set rotation direction of motor (1 or 0) ;
}
while (digitalRead(10) == HIGH) { // Volume down pressed
digitalWrite(in1, 1); // set speed of motor to high
digitalWrite(in2, 0); // set rotation direction of motor (1 or 0
}
}