I would like to thank Zoomkat over on the Arduino forums for the code. It does pretty much what I am looking for, but I want to rotate the servo using the 2ch 315 Mhz toggle T/R kit instead of a button or switch.
I would like to try to slow down the rotation a hair, so I increased the delay, but that didn't really do anything, is that the right idea?
In the code it has int press1 = 0. I know that it is referring to the button connected to pin 4, but what is the 0 doing, setting pin 4 to low?
To slow down the rotation do I have to put in a line like for(pos =0; pos> 90 pos =+1)? I think that I do, but once I start putting extra lines of code, I always get errors concerning the location of curly braces.
One more quick question and hopefully it is possible. This whole thing is for a costume and size is a big deal where the servo board is going to be located. I just bought 3 of the ATtiny trinkets hoping that they would be able to do the same thing as this code (once it works). Now I know the ATtiny85 is only an 8-bit chip and the IDE uses 16-bit. Is it possible to get the trinket to work like this? I installed the ATtiny library on my IDE, but I wasn't sure if the Servo8bit library would work.
Any help, ideas, or pointers in the right direction would be fantastic.
Hopefully I followed all the protocols for posting code and my questions, if not let me know and I will correct it.
Thanks for your help,
JC
Code: Select all
//zoomkat servo button test 12-29-2011
#include <Servo.h>
int button1 = 4; //button pin, connect to ground to move servo
int press1 = 0; //[color=#0080FF]What does this mean[/color][/color]
int button2 = 5; //button pin, connect to ground to move servo
int press2 = 0; //[color=#0080FF] same here[/color]
Servo servo1;
int pos = 0;
void setup()
{
pinMode(button1, INPUT);
pinMode(button2, INPUT);
servo1.attach(9);
digitalWrite(4, HIGH); //enable pullups to make pin high
digitalWrite(5, HIGH); //enable pullups to make pin high
}
void loop()
{
press1 = digitalRead(button1);
if (press1 == LOW)
{
servo1.write(0);
delay(500);
}
press2 = digitalRead(button2);
if (press2 == LOW)
{
servo1.write(90);
delay(500);
}
}