Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add detail comments #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions sname.ino
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <SoftwareSerial.h>

//pin location
int mo1 = 7;
int mo2 = 2;
Expand All @@ -16,6 +17,7 @@ char K;
float cm;
SoftwareSerial BTSerial(0, 1);
char val;

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Expand Down Expand Up @@ -55,7 +57,7 @@ void loop() {
cm = pulseIn(echo, HIGH) / 58.0;
delay(5);
Serial.println(cm);
if (K == '1') { //前進
if (K == '1') { //前進 go straight
digitalWrite(mo1, LOW);
digitalWrite(mo2, HIGH);
digitalWrite(mo3, HIGH);
Expand All @@ -65,7 +67,7 @@ void loop() {

}

if (K == '2') { //左轉
if (K == '2') { //左轉 turn left
digitalWrite(mo1, LOW);
digitalWrite(mo2, HIGH);
digitalWrite(mo3, HIGH);
Expand All @@ -75,7 +77,7 @@ void loop() {

}

if (K == '3') { //右轉
if (K == '3') { //右轉 turn right
digitalWrite(mo1, LOW);
digitalWrite(mo2, HIGH);
digitalWrite(mo3, HIGH);
Expand All @@ -84,7 +86,7 @@ void loop() {
analogWrite(mo6, 140);

}
if (K == '4') { //後退
if (K == '4') { //後退 turn back
digitalWrite(mo1, HIGH);
digitalWrite(mo2, LOW);
digitalWrite(mo3, LOW);
Expand All @@ -93,7 +95,7 @@ void loop() {
analogWrite(mo6, mo6v);

}
if (K == '5') { //空檔
if (K == '5') { //空檔 stall
digitalWrite(mo1, HIGH);
digitalWrite(mo2, LOW);
digitalWrite(mo3, HIGH);
Expand All @@ -102,7 +104,7 @@ void loop() {
analogWrite(mo6, 0);

}
if (K == '6') { //煞車
if (K == '6') { //煞車 break
digitalWrite(mo1, HIGH);
digitalWrite(mo2, HIGH);
digitalWrite(mo3, HIGH);
Expand All @@ -111,7 +113,7 @@ void loop() {
analogWrite(mo6, 255);

}
if (K == '8') { //加速前進
if (K == '8') { //加速前進 high straight
digitalWrite(mo1, LOW);
digitalWrite(mo2, HIGH);
digitalWrite(mo3, HIGH);
Expand Down