Coder Social home page Coder Social logo

servo8bit's Introduction

See this code in action: https://www.youtube.com/watch?v=UvY2BeQav8k

Version History
---------------
0.7
-Bug fix: If detach() was called on a servo then subsequent calls to attach() would fail.
The detach() function now works properly.


0.6
-Added ability to easily select if this driver should use timer0 or timer1.
-Timer1 is now the default timer used. Used to be timer0.
-Made the timer init happen later to allow this driver to work when used with an attiny arduino library.
-Fixed bug where a 512 microsecond pulse would not be generated.

    
0.5 
-Initial public release



Short Guide On How To Compile
------------------------------
1) Make sure you have WinAvr installed (http://winavr.sourceforge.net/)
2) open a CMD window and navigate to the Servo8Bit folder
3) type in "make" in the CMD window and the code will be compiled
4) type in "make program" to program your Attiny. This assumes you are using a
   usb programmer (such as the AVRISP mkII).

servo8bit's People

Contributors

federicobusero avatar fri000 avatar justjoheinz avatar larsks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

servo8bit's Issues

Library problem

Hi guys, i have tried to load this library with this support: https://goo.gl/Viu6aQ
I edited the example in this way:

#include "Servo8Bit.h"

void mymydelay(uint16_t milliseconds);  //forward declaration to the mydelay function
Servo8Bit myServo;
void setup() {
  myServo.attach(1);

}

int test()
{
    myServo.write(0);   //rotate to the 0 degree position
    mydelay(2000);        //wait 2 seconds

    myServo.write(180); //rotate to the 180 degree position
    mydelay(2000);        //wait 2 seconds

    myServo.write(90);  //rotate to the center (90 degree) position
    mydelay(2000);        //wait 2 seconds


    //sweep the servo
    while(1)
    {
        for(int pos = 0; pos < 180; pos++)  // goes from 0 degrees to 180 degrees
        {                                   // in steps of 1 degree
            myServo.write(pos);             // tell servo to go to position in variable 'pos'
            mydelay(15);                      // waits 15ms for the servo to reach the position
        }

        for(int pos = 180; pos > 1; pos--)  // goes from 180 degrees to 0 degrees
        {
            myServo.write(pos);             // tell servo to go to position in variable 'pos'
            mydelay(15);                      // waits 15ms for the servo to reach the position
        }
    }
}

void mydelayMicroseconds(uint16_t us)
{
#if F_CPU >= 16000000L
    // for the 16 MHz clock on most Arduino boards

    // for a one-microsecond mydelay, simply return.  the overhead
    // of the function call yields a mydelay of approximately 1 1/8 us.
    if (--us == 0)
        return;

    // the following loop takes a quarter of a microsecond (4 cycles)
    // per iteration, so execute it four times for each microsecond of
    // mydelay requested.
    us <<= 2;

    // account for the time taken in the preceeding commands.
    us -= 2;
#else
    // for the 8 MHz internal clock on the ATmega168

    // for a one- or two-microsecond mydelay, simply return.  the overhead of
    // the function calls takes more than two microseconds.  can't just
    // subtract two, since us is unsigned; we'd overflow.
    if (--us == 0)
        return;
    if (--us == 0)
        return;

    // the following loop takes half of a microsecond (4 cycles)
    // per iteration, so execute it twice for each microsecond of
    // mydelay requested.
    us <<= 1;

    // partially compensate for the time taken by the preceeding commands.
    // we can't subtract any more than this or we'd overflow w/ small mydelays.
    us--;
#endif

    // busy wait
    __asm__ __volatile__ (
        "1: sbiw %0,1" "\n\t" // 2 cycles
        "brne 1b" : "=w" (us) : "0" (us) // 2 cycles
    );
}//end mydelayMicroseconds


void mydelay(uint16_t milliseconds)
{
    for(uint16_t i = 0; i < milliseconds; i++)
    {
        mydelayMicroseconds(1000);
    }
}//end mydelay

void loop() {
  test();
  }

When i try it, the servo motor still not work.

What did I do wrong?

Thx Dave.

dummy variable mandatory for code to start

hello,

thanks a lot for your code.
It will be very usefull for my current project.
The example is working perfectlly (after changing makefile to use attiny45 and setting fuses).
(i'm using linux, and avrdude as programer)

However, i noticed somthing that i can't understand :

this function is working :
int main()
{
Servo8Bit myServo; //create a servo object.
myServo.attach(1); //attach the servo to pin PB1
int nothing = 0;
while(1)
{
myServo.write(85); //rotate
delay(1000); //wait
myServo.write(95);
delay(1000);
}
}

but this function is not working :

int main()
{
Servo8Bit myServo; //create a servo object.
myServo.attach(1); //attach the servo to pin PB1
// int nothing = 0;
while(1)
{
myServo.write(85); //rotate
delay(1000); //wait
myServo.write(95);
delay(1000);
}
}

a dummy variable has to be declare, otherwise the code won't start.
Do you have a logic explanation?

best

Servo8Bits header file

Hi,
I am using Servo8Bits. h and Servo8bits. cpp files for my ATtiny45 MCU to drive a servo motor.
I managed to run the servo motor (Hi-Tec, HS-422) but the turning speed is very slow even my delay time is very short.
How to make the turning speed faster ?

Note: Servo8Bits.h and Servo8Bits.cpp got from below link.
https://github.com/fri000/Servo8Bit

Thank you.

Error compiling

Hi
i have used your example code to drive servo but while uploading
Here's the error. Thanks !!!

libraries/Servo8Bit-master/example.cpp.o (symbol from plugin): In function delayMicroseconds(unsigned int)': (.text+0x0): multiple definition of main'
sketch/sketch_oct10c.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board ATtiny25/45/85.

declaration of map in Servo8bit class hinder global map

Hello

When a class is derived from Servo8bit and in one of the method of the derived class map is called thje compiler complains about map being private.

2 solutions :

  • make map public
  • use the map available in the Arduino Software

Best regards

Servo8Bit & Arduino 1.6.9

@fri000 :
I recently started to use Servo8Bit on an attiny85, together with Arduino 1.6.9.
In order to get it to work I needed to make some fundamental/hackish updates to the library.

Are you still active with this library ?

If so, I will make a detailed issue with config & updates I made, so we can see whether this is caused by my misunderstanding or a misalignment between the Arduino & servo8Bit librarries.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.