บทความ

งานที่ 18 หุ่นยนต์หลบสิ่งกีดขวาง Arduino 2WD

รูปภาพ
HARDWARE SOFTWARE #include <NewPing.h> //Tell the Arduino where the sensor is hooked up NewPing sonar(10, 11); int enableA = 3; int pinA1 = 6; int pinA2 = 7; int enableB = 5; int pinB1 = 8; int pinB2 = 9; long inches; void setup() {   pinMode(enableA, OUTPUT);   pinMode(pinA1, OUTPUT);   pinMode(pinA2, OUTPUT);   pinMode(enableB, OUTPUT);   pinMode(pinB1, OUTPUT);   pinMode(pinB2, OUTPUT);   pinMode(2, OUTPUT);   pinMode(12, OUTPUT);   pinMode(13, OUTPUT); } void loop() {   //Run the motors at slightly less than full power   analogWrite(enableA, 200);   analogWrite(enableB, 200);   //Ping the sensor and determine the distance in inches   inches = sonar.ping_in();   //If the robot detects an obstacle less than four inches away, it will back up, then turn left; if no obstacle is detected, it will go forward   if (inches < 5) {     analogWrite(enableA, 255);     analogWrite(e...

งานที่ 17 หุ่นยนต์ Arduino UNO + L298P บังคับด้วย Bluetooth

รูปภาพ
HARDWARE SOFTWARE /*     Bluetooth Robot with Arduino UNO + L298P     For more details visit:     https://robotsiam.blogspot.com/2017/12/uno-l298p-bluetooth.html */ #include <SoftwareSerial.h> int incomingByte = 0; /*-------definning Outputs------*/ int MA1 = 12;     // Motor A1 int MA2 =  3;     // Motor A2 int PWM_A =  10;   // Speed Motor A int MB1 =  13;     // Motor B1 int MB2 =  8;     // Motor B2 int PWM_B =  11;  // Speed Motor B int SPEED = 200;  // Speed PWM สามารถปรับความเร็วได้ถึง 0 - 255 void setup() {   //Setup Channel A   pinMode(12, OUTPUT); //Motor A1   pinMode(3, OUTPUT); //Motor A2   pinMode(10, OUTPUT); //Speed PWM Motor A   //Setup Channel B   pinMode(13, OUTPUT);  //Motor B1   pinMode(8, OUTPUT);  //Motor B2   pinMode(11, OUTPUT); //Speed PWM Motor B   Serial.begin(...