Posts

smart AGRICULTURE part1|| vcb ea.

Image
Subscribe here Components required: 1.   Arduino uno 2. 5V Motor pump 3. Bread board 4. OLED display 5. Capacitive soil moisture sensor Circuit connections are given below the code. Demo video is also available. #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define OLED_RESET 4 Adafruit_SSD1306 display(OLED_RESET); const int AirValue = 790;    const int WaterValue = 390; int intervals = (AirValue - WaterValue)/3;   int soilMoistureValue = 0; int soilmoisturepercent=0;   void setup() {   // put your setup code here, to run once:   pinMode(A0,INPUT);   pinMode(4,OUTPUT);   Serial.begin(9600);   display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //initialize with the I2C addr 0x3C (128x64)   display.clearDisplay(); } void loop() {   // put your main code here, to run repeatedly:   soilMoistureValue = analogRead(A0);  //put Sensor insert into soil   Serial.println(soilM...

basic interfacing with servo motor.

THIS CODE WILL ROTATE THE SERVO MOTOR FROM 0 TO 180 AND 180 TO 0 FOR EVERY 3 SECONDS. THIS IS THE BASIC INTERFACING OF SERVO MOTOR WITH ARDUINO UNO WHICH MAY BE HELPFUL FOR BUILDING LARGER PROJECTS. #include <Servo.h> Servo servo; int angle = 0; void setup() {   servo.attach(3); } void loop() {   for(angle = 0;angle<181;angle++)   {     servo.write(angle);   }   delay(3000);   for(angle = 180;angle>0;angle--)   {     servo.write(angle);   }   delay(3000); }

controlling servo motor based on the speed measured by the ultrasonic sensor in tinker cad

  code: controlling servo motor based on the speed measured by the ultrasonic sensor in tinker cad #include<math.h> #include <Servo.h> Servo servo1; int trigPin = 8; int echoPin = 8; float distance; float duration; void setup() { Serial.begin(9600); servo1.attach(7); servo1.write(0);// put your setup code here, to run once: } void loop() { float dist1=ultra(); delay(1000); float dist2=ultra(); float speed =0; speed = abs(dist2-dist1); Serial.println(speed); if(speed>20) { servo1.write(90); Serial.println(dist1); } } float ultra(){ pinMode(trigPin, OUTPUT); digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); pinMode(echoPin, INPUT); duration = pulseIn(echoPin, HIGH); distance = duration*0.034/2; return distance; } for any queries related to this , contact me on instagram: https://www.instagram.com/vamsikrishna_852/