Hi. This is a re-post of the one I submitted in August last year. The reason I did not pursue it is that I got the project working perfectly. Now, however it has decided not to cooperate and I am left with the original problem of very low voltage on the output pins of a ATTINY85 microprocessor. Low, meaning, 700 millivolts or so.
I have a 5 volt supply, a LED on pin5 flashing once every 30 seconds, which it does, and pin6 is connected to the base pin of a BC547 transistor. This is supposed to switch on a small motor once every minute but there is not enough voltage coming off pin6 for this to happen. As I said, I did have it working perfectly a few weeks ago and can't understand why it won't work now. Can anyone come up with a solution please. Thank you in advance.
Enclosed is the schematic in PDF format and a copy of the sketch I am using. I am using a Arduino Uno to program it and to power it. It verifies okay and uploads okay. If I connect a wire from the 5 volt rail to pin6, the motor spins without any problem. At the end of the setup, I power the LED and motor to confirm their operation and they work okay. So I assume there is fault in the code somewhere. Sorry, but it appears that I am not allowed to include attachments for some reason.
Bob May
Hi again. Thank you to the people who have responded to my post. Sorry for the lack of information, it was the end of a long frustrating day and I should have read the Forum Rules. I did try to upload the files but the site would not allow me to do so, though it appears to be working now. Anyhow, a JPEG image of the schematic has been included plus the sketch I am using.
What I know so far:-
When the sketch is run and the Setup completes, the LED flashes and the motor turns.
If I connect pin5 to the +5 volt base rail, the LED remains on until disconnected.
If I connect pin6 to the +5 volt base rail, the motor turns until disconnected.
This, to me, proves the the circuits from the pins are correct and that the problem lies with the ATTINY itself or the code.
I have tried the motor circuit on different pins, altering the pin assignments to suit, and have the same result.
I have also tried different ATTINY'S with the same result further suggesting that the problem lies within the code.
Before Christmas, I had the project working perfectly for 3 weeks continuously using the same code.
Motor information. Voltage 3V - 5V
current 0.016A @ 5V
Resistance across the terminals 30.6 Ohms
If any more information is required, i will do my best to provide it.
Thank you again for your help.
// R G May 31 July 2022
/*
Pin1 PB5 Pin8 Vcc
Pin2 PB3 Pin7 PB2
Pin3 PB4 Pin6 PB1
Pin4 GND Pin5 PB0
*/
const long kMotorOff = 1; // Motor delay time (minutes)
const int kMotorOn = 100; // Motor run time (milliseconds)
const long kLedOff = 30; // LED delay time (seconds)
const int kLedOn = 1000; // LED on time (milliseconds)
const int kMotorPin = 1; // Arduino digital pin 5; ATtiny85 digital pin PB1, physical pin 6
const int kLedPin = 0; // Arduino digital pin 2; ATtiny85 digital pin PB0, physical pin 5
unsigned long previousMillis = 0;
unsigned long previousMillis1 = 0;
int ledState = LOW; // ledState used to set the LED
int motorState = LOW; // motorState used to set the motor
long Mot_Off; //length of time in milliseconds the motor is off
int Mot_On; //length of time in milliseconds the motor is on
long Led_Off; //length of time in milliseconds the LED is off
void setup() {
//set the GPIO pins 0 and 1 to OUTPUT
pinMode(kLedPin, OUTPUT);
pinMode(kMotorPin, OUTPUT);
Mot_Off = kMotorOff * 60 * 1000; // calculates and stores the motor off time in milliseconds
Mot_On = kMotorOn; //stores the time the motor is on
Led_Off = kLedOff * 1000; // calculates and stores the LED off time in milliseconds
// Confirms the system is powered up and basically working and that the Setup has completed
ledState = HIGH;
digitalWrite(kLedPin, ledState);
delay (500);
ledState = LOW;
digitalWrite(kLedPin, ledState);
delay (500);
motorState = HIGH;
digitalWrite(kMotorPin, motorState);
delay (150);
motorState = LOW;
digitalWrite(kMotorPin, motorState);
}//end setup
void loop() {
// LED SECTION PB0
unsigned long currentMillis = millis(); //stores the current time in milliseconds
if (currentMillis - previousMillis >= Led_Off) { //Compares the elapsed time with the value held in previousMillis
previousMillis = currentMillis; // saves the last time the LED was on
if (ledState == LOW) {
for (int index = 0; index <= kLedOn; index++) { //If the led is off then the led is switched on for the time equivilent to the value stored in kLedOn
ledState = HIGH; //switches on the LED
digitalWrite(kLedPin, ledState); //puts a high voltage onto pin PB0
} // end of for loop
ledState = LOW; //switches off the LED
digitalWrite(kLedPin, ledState); //switches back to a low voltage on PB0
} //end of if
else {
ledState = LOW;
} // end of else
} //end of if
// MOTOR SECTION PB1
unsigned long currentMillis1 = millis(); //stores the current time in milliseconds
if (currentMillis1 - previousMillis1 >= Mot_Off) { //Compares the elapsed time with the value held in previousMillis
previousMillis1 = currentMillis1; // saves the last time the motor was on
if (motorState == LOW) {
for (int index1 = 0; index1 <= Mot_On; index1++) { //If the motor is off then the motor is switched on for the time equivilent to the value stored in mot_On
motorState = HIGH;
digitalWrite(kMotorPin, motorState);
} //end of for loop
motorState = LOW;
digitalWrite(kMotorPin, motorState);
} // end of if
else {
motorState = LOW;
digitalWrite(kMotorPin, motorState);
} //end of else
} //end of if
}//end of loop
type or paste code here
