Hi all,
I'm struggling with servo library for servos: <Servo.h>, used in ATtiny84 programmed by Arduino.
I did program the ATtiny84 using Arduino Uno without problems and my current wiring looks as follows: testing_platform (in the attachment).
Then I tried the servo library only with Arduino and it also worked without problems.
But if I try to add the servo to the ATtiny84 wiring it is not working at all: testing_platform_servo (in the attachment).
As shown in the wiring, I'm using physical pin: 7, which should be addressed as pin number: 6.
I also tried many of other libraries but either not possible to compile or not working...
I think something is wrong with the servo library working on ATtiny84 because if I only add the library without even wiring the servo, the display starts blinking...
The code is as follows:
#include <Arduino.h>
#include <TM1637Display.h>
#include <Servo.h> // <= Servo
//#include <Servo8Bit.h>
//#include <TinyServo.h>
//#include <PWMServo.h>
// Module connection pins (Digital Pins)
#define CLK 7
#define DIO 8
#define STA 1
#define HRS 2
#define MIN 3
#define REFRESH 1000
#define BUTT_DELAY 200
//Global settings
int gBright = 1;
//Global variables
int gHrs = 0;
int gMin = 0;
int gSec = 0;
int gStart = 0;
int gShowDoubleDot = 0;
long gLastTime = 0;
int gLockButtons = 0;
int pos = 0;
//
Servo servo; // <= Servo
TM1637Display display(CLK, DIO);
//---------------------------------------------------
// Setup
//---------------------------------------------------
void setup()
{
//Pin seetings
pinMode(STA, INPUT);
pinMode(HRS, INPUT);
pinMode(MIN, INPUT);
//Switch ON => 00:00
uint8_t data[] = { 0xff, 0xff, 0xff, 0xff };
display.setBrightness(gBright);
display.setSegments(data);
display.showNumberDec(0, true);
//Servo
servo.attach(6); // <= Servo
}
//--------------------------------------------------
// Main Loop
//--------------------------------------------------
void loop()
{
//Start/Stop
if (digitalRead(STA) == LOW
&& digitalRead(HRS) == LOW
&& digitalRead(MIN) == HIGH) {
if (pos == 0) {
pos = 90;
} else {
pos = 0;
}
servo.write(pos); // <= Servo
display.showNumberDecEx(pos, (0x80 >> 0), true);
delay(1000);
}
}
Could you please advice?
Thank you.

