Technical, Techniques, Hints, and Tips > Microprocessor control
ARDUINO any one?
C-3PO:
Want to make a servo sweep from side to side. Servo needs to be powered by an external power source (battery)
2 electrical connections to Arduino -
* Arduino "GND" ground - Battery/servo negative
* Arduino Pin 9 - to servo signal line
Sketch code below (text after "//" double lines is text notation to help understand the code and is not executed as part of the sketch(program)
--- Quote ---#include <Servo.h>
Servo myservo; // create servo object to control a servo
int pos = 0; // variable to store the servo position
void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop() {
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}
--- End quote ---
essex2visuvesi:
Interesting,
You can even have a play for free without having to buy an arduino
https://123d.circuits.io/lab
richald:
Something else I have just found - online Arduino compile/downlad/test
https://codebender.cc/
https://codebender.cc/libraries
can't comment beyond that from my brief inspection, seems fairly competent.
Richard
essex2visuvesi:
Just played on the link I posted in my last post and it did exactly what it should do
I'm ordering one.....
Merry xmas to me :)
C-3PO:
essex2visuvesi - Simulator love it!
--- Quote ---https://123d.circuits.io/lab
--- End quote ---
C-3PO
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version