Posts

Showing posts from December, 2020

SIP CAR Code BLUETOOTH

 BLUETOOTH #define MAX_PACKETSIZE 32    //Serial receive buffer char buffUART[MAX_PACKETSIZE]; unsigned int buffUARTIndex = 0; unsigned long preUARTTick = 0; struct car_status{   int speed;   int angle;   int direct; }; int move_speed=100 ; #define MAX_SPEED  250 #define MIN_SPEED  50 #define TURN_SPEED  70 #define SLOW_TURN_SPEED  50 #define BACK_SPEED  60 int buttonState; char old_status='0'; #define speedPinR 9   //  RIGHT WHEEL PWM pin D45 connect front MODEL-X ENA  #define RightMotorDirPin1  22    //Front Right Motor direction pin 1 to Front MODEL-X IN1  (K1) #define RightMotorDirPin2  24   //Front Right Motor direction pin 2 to Front MODEL-X IN2   (K1)                                  #define LeftMotorDirPin1  26    //Left front Motor direction pin 1 to Front MODEL-X IN3 (  K3) #define LeftMotorDirPin2  28   //Left front Motor direction pin 2 to Front MODEL-X IN4 (  K3) #define speedPinL 10   // Left WHEEL PWM pin D7 connect front MODEL-X ENB #define speedPinRB 11   //  R

SIP CAR Code Ultra Sonic

 ULTRASONIC SENSOR #include <Servo.h> #define speedPinR 9   //  RIGHT WHEEL PWM pin D45 connect front MODEL-X ENA  #define RightMotorDirPin1  22    //Front Right Motor direction pin 1 to Front MODEL-X IN1  (K1) #define RightMotorDirPin2  24   //Front Right Motor direction pin 2 to Front MODEL-X IN2   (K1)                                  #define LeftMotorDirPin1  26    //Left front Motor direction pin 1 to Front MODEL-X IN3 (  K3) #define LeftMotorDirPin2  28   //Left front Motor direction pin 2 to Front MODEL-X IN4 (  K3) #define speedPinL 10   // Left WHEEL PWM pin D7 connect front MODEL-X ENB #define speedPinRB 11   //  RIGHT WHEEL PWM pin connect Back MODEL-X ENA  #define RightMotorDirPin1B  5    //Rear Right Motor direction pin 1 to Back MODEL-X IN1 (  K1) #define RightMotorDirPin2B 6    //Rear Right Motor direction pin 2 to Back MODEL-X IN2 (  K1)  #define LeftMotorDirPin1B 7    //Rear left Motor direction pin 1 to Back MODEL-X IN3  K3 #define LeftMotorDirPin2B 8  //Rear le

SIP Car Code FBRL

 JugueBot Car Movement #define SPEED 100     #define TURN_SPEED 100     #define speedPinR 9   //  Front Wheel PWM pin connect Right MODEL-X ENA  #define RightMotorDirPin1  22    //Front Right Motor direction pin 1 to Right MODEL-X IN1  (K1) #define RightMotorDirPin2  24   //Front Right Motor direction pin 2 to Right MODEL-X IN2   (K1)                                  #define LeftMotorDirPin1  26    //Front Left Motor direction pin 1 to Right MODEL-X IN3 (K3) #define LeftMotorDirPin2  28   //Front Left Motor direction pin 2 to Right MODEL-X IN4 (K3) #define speedPinL 10   //  Front Wheel PWM pin connect Right MODEL-X ENB #define speedPinRB 11   //  Rear Wheel PWM pin connect Left MODEL-X ENA  #define RightMotorDirPin1B  5    //Rear Right Motor direction pin 1 to Left  MODEL-X IN1 ( K1) #define RightMotorDirPin2B 6    //Rear Right Motor direction pin 2 to Left  MODEL-X IN2 ( K1)  #define LeftMotorDirPin1B 7    //Rear Left Motor direction pin 1 to Left  MODEL-X IN3  (K3) #define LeftMotor

SIP Car Code Encoders

 JugueBot Code Wheel Encoders  #define outputA 6  #define outputB 7  int counter = 0;   int aState;  int aLastState;    void setup() {     pinMode (outputA,INPUT);    pinMode (outputB,INPUT);        Serial.begin (9600);    // Reads the initial state of the outputA    aLastState = digitalRead(outputA);     }   void loop() {     aState = digitalRead(outputA); // Reads the "current" state of the outputA    // If the previous and the current state of the outputA are different, that means a Pulse has occured    if (aState != aLastState){           // If the outputB state is different to the outputA state, that means the encoder is rotating clockwise      if (digitalRead(outputB) != aState) {         counter ++;      } else {        counter --;      }      Serial.print("Position: ");      Serial.println(counter);    }     aLastState = aState; // Updates the previous state of the outputA with the current state  }