diff options
| author | abel <71026016+ableTI@users.noreply.github.com> | 2024-04-04 16:22:44 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-04 16:22:44 +0200 |
| commit | 8090bcd5a35db3c9b63315ec99cc3e694c64974b (patch) | |
| tree | f8bcd80c6e85c2576f881183f81e0133d5f5a922 /motordriver/motordriver.ino | |
| parent | ea31038acf4e3321158ff676a1a6075db8959bcd (diff) | |
| download | robotica-8090bcd5a35db3c9b63315ec99cc3e694c64974b.tar.gz robotica-8090bcd5a35db3c9b63315ec99cc3e694c64974b.zip | |
Update motordriver.ino
Diffstat (limited to 'motordriver/motordriver.ino')
| -rw-r--r-- | motordriver/motordriver.ino | 50 |
1 files changed, 20 insertions, 30 deletions
diff --git a/motordriver/motordriver.ino b/motordriver/motordriver.ino index b8918c1..ac1f13b 100644 --- a/motordriver/motordriver.ino +++ b/motordriver/motordriver.ino @@ -8,8 +8,10 @@ int in3 = 4; int in4 = 5; // motor three int enC = 37; -int in5 = 8; -int in6 = 9; +int in5 = 7; +int in6 = 6; + +int sp = 50; void setup() { @@ -95,35 +97,22 @@ void demoTwo() digitalWrite(in5, LOW); digitalWrite(in6, LOW); } -void forward(speed, direction) + +void forward() { - // this function will run the motors across the range of possible speeds - // note that maximum speed is determined by the motor itself and theoperating voltage - // the PWM values sent by analogWrite() are fractions of the maximumspeed possible - // by your hardware - // turn on motors + sp = 160; + analogWrite(enA, sp); + analogWrite(enB, sp); + analogWrite(enC, sp); + digitalWrite(in1, LOW); - digitalWrite(in2, LOW); + digitalWrite(in2, HIGH); digitalWrite(in3, LOW); - digitalWrite(in4, LOW); + digitalWrite(in4, HIGH); digitalWrite(in5, LOW); - digitalWrite(in6, LOW); - // accelerate from zero to maximum speed - for (int i = 0; i < 256; i++) - { - analogWrite(enA, i); - analogWrite(enB, i); - analogWrite(enC, i); - delay(20); - } - // decelerate from maximum speed to zero - for (int i = 255; i >= 0; --i) - { - analogWrite(enA, i); - analogWrite(enB, i); - analogWrite(enC, i); - delay(20); - } + digitalWrite(in6, HIGH); + delay(2000); + // now turn off motors digitalWrite(in1, LOW); digitalWrite(in2, LOW); @@ -134,8 +123,9 @@ void forward(speed, direction) } void loop() { - demoOne(); - delay(1000); - demoTwo(); + //demoOne(); + //delay(1000); + //demoTwo(); delay(1000); + forward(); } |
