Hello again
I'm having issues with another project and was hoping I could get some assistance.
Here's a photo of the schematic from the book:
I have used some different pins but the idea is the same, here is my set up:
In order from right to left the components are:
-
Push button - puts arduino in either "on" or "off" mode. Button must be pressed to send power to integrated circuit. Signal runs to pin 12 on uno.
-
Push button - used to switch state so that 5v is sent to a different pin on the integrated circuit. This is wired to pin 11.
-
Potentiometer - control amount of voltage to VC pin on IC - this is wired to pin A0
-
Integrated Circuit the "tab" or cut out is on the right side, so as per the documentation I believe the top right side of the IC looking at it from the top is pin #1.
In order I have:
Pin #1 - enable pin - connected to +5v on the breadboard
Pin #2 - input pin 1 - connected to pin 3
Pin #3 - output to motor
Pin #4 + #5 - ground
Pin #6 - output to motor
Pin #7 - input pin 2 - connected to pin 2
Pin #8 - VC connected to the 9v battery on the other side of the breadboard
The grounds of each side of the breadboard are connected together
I have probed with a multimetre,
I am finding pin 1 on IC: 4v
pin 2: 4.2v
pin 3: 4.24
pin 6: also 4.24v (not sure why)
pin 7: 0v (I think this is ok because only one input pin receives power)
pin 8: 8.68v from 9v battery
I am finding it pin 3 & 6 each both have 4.24 v when tested to the breadboard ground. This doesn't seem right.
I have also found that pin 3 & 6 from the IC is not distributing the power to all of the pins on the breadboard horizontally like the row is normally powered or grounded when using the 5v input from the uno.
Here is the code, I tried to copy & paste the one from the project book but it still wasn't working. I decided to try and make my own. It makes sense logically I think, but not sure what else I can try.
// constants
const int LEDPin = 13;
const int powerButton = 12;
const int directionButton = 11;
const int pot = A0;
const int enablePin = 6;
const int controlPinOne = 3;
const int controlPinTwo = 2;
// variables
bool motorRotation = false; // false for forward true for backward
bool isPowerOn = false;
int potentiometreInput;
void setup() {
Serial.begin(9600);
pinMode(powerButton, INPUT);
pinMode(directionButton, INPUT);
pinMode(pot, INPUT);
pinMode(enablePin, OUTPUT);
pinMode(controlPinOne, OUTPUT);
pinMode(controlPinTwo, OUTPUT);
pinMode(LEDPin, OUTPUT);
digitalWrite(enablePin, LOW);
}
void loop() {
// controls state for power button
if (digitalRead(powerButton) == HIGH) {
isPowerOn = !isPowerOn;
}
// function loop
if (isPowerOn) {
digitalWrite(LEDPin, HIGH);
while (isPowerOn) {
Serial.println("Power On...");
potentiometreInput = map(analogRead(pot), 0, 1023, 0, 255);
analogWrite(enablePin, potentiometreInput);
// controls state for which direction the control pins send power
if (digitalRead(directionButton) == HIGH) {
motorRotation = !motorRotation;
Serial.println(motorRotation);
}
// if both pins are for some reason high, set them both to low
if (digitalRead(controlPinOne) == HIGH && digitalRead(controlPinTwo) == HIGH) {
digitalWrite(controlPinOne, LOW);
digitalWrite(controlPinTwo, LOW);
}
// power the motor based on if the button has been pressed
if (!motorRotation) {
digitalWrite(controlPinOne, HIGH);
digitalWrite(controlPinTwo, LOW);
Serial.println("Motor now spinning forward");
Serial.println(potentiometreInput);
} else if (motorRotation) {
digitalWrite(controlPinOne, LOW);
digitalWrite(controlPinTwo, HIGH);
Serial.println("Motor now spinning backward");
Serial.println(potentiometreInput);
}
Serial.println(motorRotation);
delay(200);
// if the power button is pressed while inside the function loop, change state to "off"
if (digitalRead(powerButton) == HIGH) {
Serial.println("Unit powering off...");
delay(1000);
isPowerOn = !isPowerOn;
}
}
} else {
// just the "off" state
digitalWrite(enablePin, LOW);
digitalWrite(LEDPin, LOW);
digitalWrite(enablePin, LOW);
Serial.println("Unit now off...");
delay(200);
}
}


