Differences

This shows you the differences between two versions of the page.

Link to this comparison view

pm:prj2021:apredescu:masina_controlata_prin_bluetooth [2021/06/04 13:35]
stefan.radutoiu [Autor]
pm:prj2021:apredescu:masina_controlata_prin_bluetooth [2021/06/04 13:37] (current)
stefan.radutoiu [Autor]
Line 42: Line 42:
 ===Cod=== ===Cod===
 #include <​LiquidCrystal_I2C.h>​ #include <​LiquidCrystal_I2C.h>​
-LiquidCrystal_I2C lcd(0x27,​20,​4);​ 
 #include <​NewPing.h>​ #include <​NewPing.h>​
 #include <​SoftwareSerial.h>​ #include <​SoftwareSerial.h>​
 +
 +LiquidCrystal_I2C lcd(0x27,​20,​4);​
   // Motor A   // Motor A
    
Line 60: Line 61:
 int in2B = 8; int in2B = 8;
 int distance = 100; int distance = 100;
-SoftwareSerial HM10(0, 1); // RX = 2, TX = 3+ 
 +SoftwareSerial HM10(0, 1); 
 #define trig_pin A1 //analog input 1 #define trig_pin A1 //analog input 1
 #define echo_pin A2 //analog input 2 #define echo_pin A2 //analog input 2
Line 72: Line 75:
   // put your setup code here, to run once:   // put your setup code here, to run once:
   Serial.begin(9600);​   Serial.begin(9600);​
- HM10.begin(9600);​+  ​HM10.begin(9600);​
   pinMode(pwmA,​ OUTPUT);   pinMode(pwmA,​ OUTPUT);
   pinMode(pwmB,​ OUTPUT);   pinMode(pwmB,​ OUTPUT);
Line 93: Line 96:
   // put your main code here, to run repeatedly:   // put your main code here, to run repeatedly:
    ​HM10.listen(); ​    ​HM10.listen(); ​
-  ​if (HM10.available() > 0){+    ​if (HM10.available() > 0){
     command = HM10.read();​     command = HM10.read();​
     lcd.print(command);​     lcd.print(command);​
Line 135: Line 138:
     lcd.clear();​     lcd.clear();​
     lcd.print("​FORWARD"​);​     lcd.print("​FORWARD"​);​
-   // mode = "​forward";​ 
     delay(1000);​     delay(1000);​
-    ​//​MotorSpeed1 = 0; +    analogWrite(pwmA,​ MotorSpeed1);​ 
-    //​MotorSpeed2 = 0; +    analogWrite(pwmB,​ MotorSpeed2);​
-  ​analogWrite(pwmA,​ MotorSpeed1);​ +
-  analogWrite(pwmB,​ MotorSpeed2);​+
     ​     ​
   }   }
Line 154: Line 154:
     lcd.clear();​     lcd.clear();​
     lcd.print("​BACKWARD"​);​     lcd.print("​BACKWARD"​);​
-   // mode = "​backward";​ 
     delay(1000);​     delay(1000);​
     MotorSpeed1 = 0;     MotorSpeed1 = 0;
Line 190: Line 189:
     lcd.clear();​     lcd.clear();​
     lcd.print("​LEFT"​);​     lcd.print("​LEFT"​);​
-   // mode = "​left";​ 
     delay(1000);​     delay(1000);​
     MotorSpeed1 = 0;     MotorSpeed1 = 0;
Line 199: Line 197:
   }   }
  // turn right  // turn right
-      ​if (command == '​d'​){+    ​if (command == '​d'​){
     MotorSpeed1 = 100;     MotorSpeed1 = 100;
     MotorSpeed2 = 100;     MotorSpeed2 = 100;
Line 210: Line 208:
     lcd.clear();​     lcd.clear();​
     lcd.print("​RIGHT"​);​     lcd.print("​RIGHT"​);​
-    //mode = "​right";​ 
     delay(1000);​     delay(1000);​
     MotorSpeed1 = 0;     MotorSpeed1 = 0;
pm/prj2021/apredescu/masina_controlata_prin_bluetooth.1622802924.txt.gz · Last modified: 2021/06/04 13:35 by stefan.radutoiu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0