import org.firmata4j.IODevice; import org.firmata4j.Pin; import org.firmata4j.firmata.FirmataDevice; import org.firmata4j.ssd1306.SSD1306; import java.io.IOException; import java.util.HashMap; import java.util.TimerTask; public class minorproj extends TimerTask { static String recLog = "\"/dev/cu.usbserial-0001\""; static IODevice myGroveBoard; private final SSD1306 theOledObject; private Pin MoistureSensor; private Pin WaterPump; private Pin Button; private int sampleCount; public minorproj(SSD1306 theOledObject, Pin Button, Pin MoistureSensor, Pin WaterPump) { this.theOledObject = theOledObject; this.Button = Button; this.MoistureSensor = MoistureSensor; this.WaterPump = WaterPump; this.sampleCount = 0; } double startTime = System.currentTimeMillis(); @Override public void run() { while (true) { { // check if button is pressed if (this.Button.getValue() == 1) { break; // exit loop and stop program } String VolValue = String.valueOf(MoistureSensor.getValue()); System.out.println("Moisture Sensor Value:" + VolValue); double Moisture = (double)( ((MoistureSensor).getValue() * 5)/ 1023); HashMap Value = new HashMap<>();//used to store a mapping of keys to values. //the keys are of the data type Double and the values are of the data type Integer. double elapsedTime = (System.currentTimeMillis() - startTime) / 1000.0; if (this.MoistureSensor.getValue() >= 710) { try { System.out.println("Soil is Dry.Water!!"); theOledObject.getCanvas().clear(); // clear contents first. theOledObject.getCanvas().drawString(0, 0, "Soil is Dry.Water!!::" + String.format("%.2f", Moisture)); theOledObject.display(); WaterPump.setValue(1); } catch (IOException e) { throw new RuntimeException(e); } } else if (this.MoistureSensor.getValue() <= 510) { try { System.out.println("Soil is WET.Do Not Water!!"); theOledObject.getCanvas().clear(); // clear contents first. theOledObject.getCanvas().drawString(0, 0, "Soil is WET.Do Not Water!!::" + String.format("%.2f", Moisture)); theOledObject.display(); WaterPump.setValue(0); } catch (IOException e) { throw new RuntimeException(e); } } else try { System.out.println("Soil is Moist.Needs More Water!!"); theOledObject.getCanvas().clear(); // clear contents first. theOledObject.getCanvas().drawString(0, 0, "Soil is Moist.Needs More Water!!::" + String.format("%.2f", Moisture)); theOledObject.display(); WaterPump.setValue(1); } catch (IOException e) { throw new RuntimeException(e); } } } ---- create another class that makes this code run

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

import org.firmata4j.IODevice;
import org.firmata4j.Pin;
import org.firmata4j.firmata.FirmataDevice;
import org.firmata4j.ssd1306.SSD1306;

import java.io.IOException;
import java.util.HashMap;
import java.util.TimerTask;



public class minorproj extends TimerTask {
static String recLog = "\"/dev/cu.usbserial-0001\"";
static IODevice myGroveBoard;


private final SSD1306 theOledObject;
private Pin MoistureSensor;
private Pin WaterPump;
private Pin Button;
private int sampleCount;
public minorproj(SSD1306 theOledObject, Pin Button, Pin MoistureSensor, Pin WaterPump) {
this.theOledObject = theOledObject;
this.Button = Button;
this.MoistureSensor = MoistureSensor;
this.WaterPump = WaterPump;
this.sampleCount = 0;
}
double startTime = System.currentTimeMillis();


@Override
public void run() {
while (true) {
{
// check if button is pressed
if (this.Button.getValue() == 1) {
break; // exit loop and stop program
}
String VolValue = String.valueOf(MoistureSensor.getValue());
System.out.println("Moisture Sensor Value:" + VolValue);
double Moisture = (double)( ((MoistureSensor).getValue() * 5)/ 1023);
HashMap<Double, Integer> Value = new HashMap<>();//used to store a mapping of keys to values.
//the keys are of the data type Double and the values are of the data type Integer.
double elapsedTime = (System.currentTimeMillis() - startTime) / 1000.0;

if (this.MoistureSensor.getValue() >= 710) {
try {
System.out.println("Soil is Dry.Water!!");
theOledObject.getCanvas().clear(); // clear contents first.
theOledObject.getCanvas().drawString(0, 0, "Soil is Dry.Water!!::" + String.format("%.2f", Moisture));
theOledObject.display();
WaterPump.setValue(1);
} catch (IOException e) {
throw new RuntimeException(e);
}
} else if (this.MoistureSensor.getValue() <= 510) {
try {
System.out.println("Soil is WET.Do Not Water!!");
theOledObject.getCanvas().clear(); // clear contents first.
theOledObject.getCanvas().drawString(0, 0, "Soil is WET.Do Not Water!!::" + String.format("%.2f", Moisture));
theOledObject.display();
WaterPump.setValue(0);
} catch (IOException e) {
throw new RuntimeException(e);
}
} else
try {
System.out.println("Soil is Moist.Needs More Water!!");
theOledObject.getCanvas().clear(); // clear contents first.
theOledObject.getCanvas().drawString(0, 0, "Soil is Moist.Needs More Water!!::" + String.format("%.2f", Moisture));
theOledObject.display();
WaterPump.setValue(1);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
----

create another class that makes this code run

Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Files and Directory
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education