roller2 pin 7/8 => 2/3

- don't use pin 8, that's used for boot mode selection!
This commit is contained in:
Dooho Yi 2021-06-21 23:30:33 +09:00
parent 89bd38be01
commit a259d5116a

View file

@ -111,14 +111,14 @@ void set_speed() {
MONITORING_SERIAL.println(r); MONITORING_SERIAL.println(r);
isactive = true; isactive = true;
} }
Task set_speed_task(0, TASK_ONCE, &set_speed); Task set_speed_task(0, TASK_ONCE, &set_speed, &runner, false);
// //
void rest() { void rest() {
analogWrite(MOTOR_1A, LOW); analogWrite(MOTOR_1A, LOW);
analogWrite(MOTOR_1B, LOW); analogWrite(MOTOR_1B, LOW);
isactive = false; isactive = false;
} }
Task rest_task(0, TASK_ONCE, &rest); Task rest_task(0, TASK_ONCE, &rest, &runner, false);
// //
uint8_t watch_counter = 0; uint8_t watch_counter = 0;
void watcher() { void watcher() {
@ -133,8 +133,8 @@ void watcher() {
} }
Task watcher_task(1000, TASK_FOREVER, &watcher, &runner, true); Task watcher_task(1000, TASK_FOREVER, &watcher, &runner, true);
// //
#define MOTOR_2A (D8) #define MOTOR_2A (D3)
#define MOTOR_2B (D7) #define MOTOR_2B (D2)
// my tasks // my tasks
int speed2 = 0; int speed2 = 0;
bool isactive2 = false; bool isactive2 = false;
@ -152,14 +152,14 @@ void set_speed2() {
MONITORING_SERIAL.println(r); MONITORING_SERIAL.println(r);
isactive2 = true; isactive2 = true;
} }
Task set_speed2_task(0, TASK_ONCE, &set_speed2); Task set_speed2_task(0, TASK_ONCE, &set_speed2, &runner, false);
// //
void rest2() { void rest2() {
analogWrite(MOTOR_2A, LOW); analogWrite(MOTOR_2A, LOW);
analogWrite(MOTOR_2B, LOW); analogWrite(MOTOR_2B, LOW);
isactive2 = false; isactive2 = false;
} }
Task rest2_task(0, TASK_ONCE, &rest2); Task rest2_task(0, TASK_ONCE, &rest2, &runner, false);
// //
uint8_t watch2_counter = 0; uint8_t watch2_counter = 0;
void watcher2() { void watcher2() {
@ -390,12 +390,7 @@ void setup() {
randomSeed(analogRead(0)); randomSeed(analogRead(0));
//tasks //tasks
runner.addTask(set_speed_task);
runner.addTask(rest_task);
rest_task.restartDelayed(500); rest_task.restartDelayed(500);
//
runner.addTask(set_speed2_task);
runner.addTask(rest2_task);
rest2_task.restartDelayed(500); rest2_task.restartDelayed(500);
} }