งาน ปฏิบัติ 6
Code
#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int BS1 = 0;
int BS2 = 0;
void setup() {
pinMode(1, OUTPUT);
pinMode(0, OUTPUT);
pinMode(6, INPUT);
pinMode(7, INPUT);
lcd.begin(16, 2);
}
void loop() {
BS1 = digitalRead(6);
BS2 = digitalRead(7);
if (BS1 == LOW) {
digitalWrite(1, LOW);
digitalWrite(0, HIGH);
lcd.setCursor(7, 1);
lcd.print("RIGHT");
}
if (BS2 == LOW) {
digitalWrite(1, HIGH);
digitalWrite(0, LOW);
lcd.setCursor(7, 1);
lcd.print("LEFT");
}
ความคิดเห็น
แสดงความคิดเห็น