better understanding of pwm
This commit is contained in:
parent
60a6db9832
commit
41661cd05d
1 changed files with 5 additions and 21 deletions
|
@ -1,3 +1,4 @@
|
|||
// esp32 specific
|
||||
#include <unordered_map>
|
||||
|
||||
#include "WiFi.h"
|
||||
|
@ -188,8 +189,7 @@ std::unordered_map<char, BrailleChar> brailleMap = {
|
|||
}}}
|
||||
};
|
||||
|
||||
void setup()
|
||||
{
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
WiFi.disconnect(true);
|
||||
|
@ -206,7 +206,7 @@ void setup()
|
|||
Serial.println(WiFi.localIP());
|
||||
udp.onPacket([](AsyncUDPPacket packet) {
|
||||
Serial.print(", Length: ");
|
||||
Serial.print(packet.length()); //dlzka packetu
|
||||
Serial.print(packet.length());
|
||||
Serial.print(", Data: ");
|
||||
// Serial.write(packet.data(), packet.length());
|
||||
// that is printing a character instead of a number
|
||||
|
@ -228,32 +228,16 @@ void setup()
|
|||
ESP32PWM::allocateTimer(1);
|
||||
ESP32PWM::allocateTimer(2);
|
||||
ESP32PWM::allocateTimer(3);
|
||||
// myservo.setPeriodHertz(50); // standard 50 hz servo
|
||||
// myservo.attach(servoPin, 1000, 2000); // attaches the servo on pin x to the servo object
|
||||
// using default min/max of 1000us and 2000us
|
||||
// different servos may require different min/max settings
|
||||
// for an accurate 0 to 180 sweep
|
||||
for (int i = 0; i < 6; i++) {
|
||||
servos[i].servo.setPeriodHertz(50);
|
||||
servos[i].servo.attach(servos[i].pin, 500, 2500); // full 180
|
||||
servos[i].servo.attach(servos[i].pin);
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
void loop() {
|
||||
// delay(1000);
|
||||
// udp.broadcast("Anyone here?");
|
||||
|
||||
// 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
|
||||
// }
|
||||
|
||||
// myservo.write(bindex);
|
||||
for (int i = 0; i < 6; i++) {
|
||||
servos[i].servo.write(brailleMap[in_char].servoStates[i] * 180);
|
||||
|
|
Loading…
Add table
Reference in a new issue