make the doll's head move

Who can help me with making a servo move for a head of a doll sitting on a train.
I made a doll's head on a servo.
now he has to look from left to right and go back and forth.
I've tried something but it doesn't really work the way I want.
who oh who wants to help me.
 

lbenson

Senior Member
Let us see the code for what you tried. Which picaxe? Also, the particular servo model and maybe a photo would help give context.
 
voornaamst:
servo C.0, 175 ;poppeteje beweging

pauze 500

voor b1=175 tot 79 stap-1;kijkt op zij
servopos C.0,b1
pauze 8
volgende b1
servo C.0,uit

wacht 5

servo C.0, 79 ;poppeteje beweging

pauze 500

voor b1=79 tot 175 stap 1 ;kijkt weer naar voren
servopos C.0,b1
pauze 10
volgende b1
servo C.0,uit

ga naar hoofd
Dit is wat ik geschreven heb.
maar dan gaat ie maar een keer kip en weer.
wil eigeluk dat wil zeggen zolang ik hem actief heb heen en weer gaat.
ik gebruik de 08m2 dit inverband met de kleine inbouw
 

neiltechspec

Senior Member
What exactly do you want it to do and what is happening ?

From what you have shown, I would have done it like this.
Code:
#picaxe 08m2
#no_data

main:
servo C.0, 175

do

pause 1000

for b1=175 to 79 step-1
servopos C.0,b1
pause 8
next b1

pause 5000

for b1=79 to 175 step 1
servopos C.0,b1
pause 10
next b1

loop
 
Bedankt voor een oplossing ga het proberen.
wat ik zou willen is dat het hoofdje van link naar rechts gaat maar dan ook van recht tot het midden en dan weer een stukje terug.
zeg maar dat de omgeving verkend is
waarschijnlijk als op de tekening.
hoop dat het duidelijk is wat ik bedoel.
 

Attachments

thanks for a solution, I'll try it. what I would like is for the head to go from left to right, but then also from straight to the middle and then back a bit. say that the area has been explored, probably as shown in the drawing. hope it's clear what I mean.
 

AllyCat

Senior Member
Hi,
thanks for a solution, I'll try it. what I would like is for the head to go from left to right, but then also from straight to the middle and then back a bit. say that the area has been explored, probably as shown in the drawing. hope it's clear what I mean.
You might need to calibrate the symbols a little, but try something like:
Code:
#picaxe 08M2
#no_data
symbol Ahead = 150
symbol FullLeft = 100
symbol FullRight = 200
symbol Position = b1
symbol Seed = w2
symbol PartLeft = b6
symbol PartRight = b7
symbol SPin = C.1      ; Could be C.0, but I prefer to retain C.0 for Programming / Debugging

MoveHead:
   Position = Ahead                               ; Forwards direction
   servo SPin,Position
   pause 1000                                        ; Wait for 1 second
    do
TurnRight:
       random Seed
       PartRight = FullRight - Ahead ** Seed         ; Random distance
      PartRight = FullRight - PartRight             ; Random reduction in sweep
        do
         inc Position
          servo SPin,Position
          pause 10                                        ; Larger for slower turning
      loop until Position => PartRight            ; Then Return if subroutine
TurnLeft:
        random Seed      
       PartLeft = Ahead - FullLeft ** Seed        ; Random positive distance
       PartLeft = FullLeft + Partleft            ; Random reduction
      do
         dec Position
          servo SPin,Position
          pause 10
      loop until Position <= PartLeft            ; Then Return if subroutine
Turnforward:                                        ; From a Left offset
      do
         inc Position
          servo SPin,Position
          pause 10
      loop until Position => Ahead            
        pause 2000                                    ; Look forwards for 2 secs
    loop
The arrangement of the RANDOM function here is that the first few sweeps will be (almost) full amplitude (to assist calibration) but then the sweeps can be anything between 0% and 100% of the Full size. You could arrange some more complex and Random movements by changing the Turn.... sections into subroutines.

Cheers, Alan.
 
Last edited:
perfect
just what you say, fine adjustment and I can continue building
Thank you
May I ask something like that again in the future?
mainly did light work with the picaxe.
for flashing lights for cars
 

papaof2

Senior Member
You may always ask. No promises that someone will have an immediate answer but your are almost guaranteed that someone will eventually have an answer. There some very dedicated "Sherlock Holms and the Electronic ???" people on this forum.
Wonder if that's because PICAXE is a product of his home country ;-)
 
Top