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
Code for temperature LCD and DHT11 /* * temperature LCD and DHT11.c * * Created: 7/16/2020 7:41:41 PM * Author : Daniel F Diaz Bayona */ #include <avr/io.h> #include <stdlib.h> #include <stdio.h> #include "LCD16x2_4bit.h" #define DHT11_PIN 8 uint8_t c=0,I_RH,D_RH,I_Temp,D_Temp,CheckSum; //here we will set the pin to low and high //first the pin will be low then after 200ms delay it will show or be high void Request() { DDRD |= (1<<DHT11_PIN); PORTD &= ~(1<<DHT11_PIN); _delay_ms(200); PORTD |= (1<<DHT11_PIN); } //the following function will show th response of the sensor DHT11 void Response() { DDRD &= ~(1<<DHT11_PIN); while(PIND & (1<<DHT11_PIN)); while((PIND & (1<<DHT11_PIN))==0); while(PIND & (1<<DHT11_PIN)); } //this function will receive the data, check for received bit 0 or 1 //if the pulse is greater than 30ms //then it will set the logic or the PIN
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
Comments
Post a Comment