mirror of
https://github.com/PaulStoffregen/Tlc5940
synced 2025-09-27 10:02:20 +02:00
Import Tlc5940 version r014_2
This commit is contained in:
40
examples/Servos/Servos.pde
Normal file
40
examples/Servos/Servos.pde
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
This sketch sweeps a servo on channel 0.
|
||||
|
||||
To connect a servo:
|
||||
1. Put a 2k-5k pull-up resistor (R0 below; I've tried with 3.3k) between the
|
||||
servo control output pin and +5v.
|
||||
2. Connect that same pin to the servo's control line like so
|
||||
|
||||
servo data pin
|
||||
| _____
|
||||
OUTn ----+----[_____]---+5v
|
||||
R0
|
||||
|
||||
Steve Pomeroy <steve ~AT~ staticfree.info>, 2009-01-20 */
|
||||
|
||||
#include "Tlc5940.h"
|
||||
#include "tlc_servos.h"
|
||||
|
||||
#define SERVO_CHANNEL 0
|
||||
#define DELAY_TIME 20
|
||||
|
||||
void setup()
|
||||
{
|
||||
tlc_initServos(); // Note: this will drop the PWM freqency down to 50Hz.
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
for (int angle = 0; angle < 180; angle++) {
|
||||
tlc_setServo(SERVO_CHANNEL, angle);
|
||||
Tlc.update();
|
||||
delay(DELAY_TIME);
|
||||
}
|
||||
for (int angle = 180; angle >= 0; angle--) {
|
||||
tlc_setServo(SERVO_CHANNEL, angle);
|
||||
Tlc.update();
|
||||
delay(DELAY_TIME);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user