projects
/
challenge-bot
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
clarify lack of checking speed lower bound
[challenge-bot]
/
build-stages
/
h_stay_on_table
/
h_stay_on_table.ino
diff --git
a/build-stages/h_stay_on_table/h_stay_on_table.ino
b/build-stages/h_stay_on_table/h_stay_on_table.ino
index 07f7d17230591bea8820e73851b23957ac8f1512..48d0802d8c92643054b13e0977916078487ca58c 100644
(file)
--- a/
build-stages/h_stay_on_table/h_stay_on_table.ino
+++ b/
build-stages/h_stay_on_table/h_stay_on_table.ino
@@
-14,16
+14,16
@@
*/
// define which pins are connected to which components
*/
// define which pins are connected to which components
-int right_motor_
spee
d_pin = 3;
-int right_motor_
for
ward_pin = 4;
-int right_motor_
backwar
d_pin = 5;
+int right_motor_
forwar
d_pin = 3;
+int right_motor_
back
ward_pin = 4;
+int right_motor_
spee
d_pin = 5;
int right_echo_pin = 6;
int right_trigger_pin = 7;
int right_echo_pin = 6;
int right_trigger_pin = 7;
-int left_motor_
spee
d_pin = 8;
-int left_motor_
for
ward_pin = 9;
-int left_motor_
backwar
d_pin = 10;
+int left_motor_
forwar
d_pin = 8;
+int left_motor_
back
ward_pin = 9;
+int left_motor_
spee
d_pin = 10;
int left_echo_pin = 11;
int left_trigger_pin = 12;
int left_echo_pin = 11;
int left_trigger_pin = 12;
@@
-48,6
+48,7
@@
void set_motor(int speed_pin,
else{ // speed is 0
off(forward_pin);
off(backward_pin);}
else{ // speed is 0
off(forward_pin);
off(backward_pin);}
+ // since speed has been set positive, no need to check if speed < -255.
if(speed > 255){
speed = 255;}
analogWrite(speed_pin, speed);}
if(speed > 255){
speed = 255;}
analogWrite(speed_pin, speed);}