Surprise your friends and family with a moving doll, just follow these few simple steps.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #include <stdio.h>
#include <errno.h>
#include <string.h>
#include <drogon/wiringpi/wiringpi/wiringpi.h>
#include <drogon/wiringpi/wiringpi/softservo.h>
int main ()
{
if (wiringPiSetup () == -1)
{
fprintf (stdout, "oops: %s\n", strerror (errno));
return 1 ;
}
softServoSetup (0, 1, 2, 3, 4, 5, 6, 7) ;
softServoWrite (0, 500);
int range = 500;
int vel = 10;
for (;;){
softServoWrite (0, range);
range += vel;
if (range > 1250 || range < -250)
vel = -vel;
delay (10);
}
}
|
Download: main.cpp
As fans of the TV Show we chose to move Heisenberg paper doll for our little experiment. Feel free to be creative making your own doll:
In the following pictures you can see how we built our doll:
If you need more information about the GPIO Reference follow this link.
Signal | GPIO17 |
+ | 5v |
- | 0v |
GPIO Rev.1 | GPIO Pin Layout | GPIO Rev.2 |
Have fun with the moving doll!
Now that your doll is moving, share it with your friends and family, make them laugh. We would also be happy to see other videos online. Feel free to show us your most creative doll :)