Ultra Sonic Sensor
Ultra Sonic Sensor Code int trigPin = 12; /* Trig pin of the sensor is connected to the 6th pin of Arduino */ int echoPin = 11; /* The echo pin of the sensor is connected to the 7th Pin of the Arduino */ long Duration; //Duration long Distance; //Distance int leftMotor_1=3; //motor 1 the first data entry is HIGH OR LOW int leftMotor_2=2; //motor 1 the second data entry is HIGH OR LOW int rightMotor_1=4; //motor 2 the first data entry is HIGH OR LOW int rightMotor_2=5; //motor 2 the second data entry is HIGH OR LOW int leftMotor_pwm=6; // motor 1 Speed control is done with pwm input for // 0-255 analog PWM signal is sent in range int rightMotor_pwm=9; // motor 2 Speed control is done with pwm input for // 0-255 analog PWM signal is sent in range void setup() { for(int i=2;i<=9;i++){ pinMode(i, OUTPUT);} //2-9 No ports are set as outputs pinMode(trigPin,OUTPUT); pinMode(echoPin,INPUT); Serial.begin(9600); // loca
Comments
Post a Comment