Automation Code-1
Automation Code-1
The automation sequence is manually activated and will not engage till the right parameters are
met. The parameters are whether or not the aircraft is at the correct height to maintain stability
and collect water efficiently. These parameters will be measured by various sensors onboard
including ultrasonic sensors to detect distance from the water's surface. LED lights in
conjunction with Photovoltaic cells are used to provide light for the cells to monitor the water
level. This level of automation allows the pilots to swiftly, safely, and easily collect and transport
water.
Circuit Diagram
This circuit consists of 2 inputs and 2 outputs. The inputs are the ultrasonic sensors and the
phototransistor. The outputs are the DC motor and LED light.
Arduino Code
/*
Ping))) Sensor
This sketch reads a PING))) ultrasonic rangefinder and returns the distance
to the closest object in range. To do this, it sends a pulse to the sensor to
initiate a reading, then listens for a pulse to return. The length of the
returning pulse is proportional to the distance of the object from the sensor.
The circuit:
- +V connection of the PING))) attached to +5V
- GND connection of the PING))) attached to ground
- SIG connection of the PING))) attached to digital pin 7
https://www.arduino.cc/en/Tutorial/BuiltInExamples/Ping
*/
// this constant won't change. It's the pin number of the sensor's output:
const int pingPin = -3;
int motorPin = 4;
int Sensor = analogRead(A0);
void setup() {
Serial.begin(9600);
while (! Serial);
Serial.println("Speed 0 to 255");
// initialize serial communication:
Serial.begin(9600);
}
void loop()
{
pinMode(motorPin, OUTPUT);
Serial.begin(9600);
if (Serial.available())
{
while (! Serial);
Serial.println("Speed 0 to 255");
// establish variables for duration of the ping, and the distance result
// in inches and centimeters:
long duration, inches, cm;
// The same pin is used to read the signal from the PING))): a HIGH pulse
// whose duration is the time (in microseconds) from the sending of the ping
// to the reception of its echo off of an object.
pinMode(pingPin, INPUT);
duration = pulseIn(pingPin, HIGH);
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();
delay(100);
}
//https://create.arduino.cc/projecthub/MisterBotBreak/how-to-use-a-photoresistor-46c5eb
int value = analogRead(A0);
Serial.println("Analog value : ");
Serial.println(value);
delay(250);
if (Serial.available()) {
int speed = Serial.parseInt();
if (speed >= 0 && speed <= 255) {
analogWrite(motorPin, speed);
}
}
}
Results of Automation
With an ultrasonic sensor detecting height, the water collection system using a motor will lower
the hose into the water to start the collection process. Using a LED light in the water holding
tank and phototransistors I can measure the level of the tank by seeing if the transistors are
obstructed by the water or not.