กลับทางมอเตอร์
Code
#include <LiquidCrystal.h>
LiquidCrystal lcd(13, 12, 4, 5, 6, 7);
int BS1,BS2;
void setup()
{
lcd.begin(16, 2);
pinMode(11, INPUT);
pinMode(10, INPUT);
pinMode(1,OUTPUT);
pinMode(0,OUTPUT);
pinMode(0,OUTPUT);
}
void loop()
{
BS1 = digitalRead(11);
BS2 = digitalRead(10);
BS1 = digitalRead(11);
BS2 = digitalRead(10);
if (BS1 == LOW) {
digitalWrite(0, HIGH);
digitalWrite(1, LOW);
digitalWrite(0, HIGH);
digitalWrite(1, LOW);
lcd.setCursor(7, 0);
lcd.print("LEFT");
lcd.print("LEFT");
}
else if (BS2 == LOW) {
digitalWrite(1, HIGH);
digitalWrite(0, LOW);
else if (BS2 == LOW) {
digitalWrite(1, HIGH);
digitalWrite(0, LOW);
lcd.setCursor(7, 0);
lcd.print("right");
lcd.print("right");
}
else {
lcd.setCursor(5, 0);
lcd.print("++Stop++");
digitalWrite(0, LOW);
digitalWrite(1, LOW);;
}
else {
lcd.setCursor(5, 0);
lcd.print("++Stop++");
digitalWrite(0, LOW);
digitalWrite(1, LOW);;
}
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น