Code

Maps


temp = map(analogRead(A2), 0, 1023, 60, 170) ;
soil = map(analogRead(A0), 0, 1023, 0, 100);
humidity = map(analogRead(A3), 0, 1023, 0, 100);
gas = map(analogRead(A1), 0, 1023, 0, 100);
							

To return useable values that make sense to the user, we mapped each analogRead output either to a range of temperatures that would be recognizeale, or to a 0-100 scale so as to show a percentage of each parameter rather than an arbitrary number.

Logic


if(analogRead(A0)<=800)
{
	digitalWrite(5, LOW);
	lcd.clear();
	lcd.home();
	lcd.print("Spinning!");
	delay(10);
}
else  if(analogRead(A1)<=800)
{
	digitalWrite(4, LOW);
	lcd.clear();
	lcd.home();
	lcd.print("Adding leaves!");
	delay(10);
								 
}
else  if(temp<=120)
{
	digitalWrite(6, LOW);
	lcd.clear();
	lcd.home();
	lcd.print("Heating!");
	delay(10);
}
							

Each component of the Smart Composter is triggered by a relay which fires once the sensor that corresponds to a necessary parameter of compost goes above or below the desired range. To alert the user of what systems are running in the composter, the mounted LCD displays different text based on what process it is undergoing. Each component's logic needed to be put in the same if statement so as not to have the action displays overlap.

Default Display


else{
	digitalWrite(5, HIGH);
	digitalWrite(4, HIGH);
	digitalWrite(6, HIGH);
	temp = map(analogRead(A2), 0, 1023, 60, 170) ;
	soil = map(analogRead(A0), 0, 1023, 0, 100);
	lcd.clear();
	lcd.home();
	lcd.print("TempF:");
	lcd.print(temp);
	lcd.print(" O2:");
	lcd.print(gas);
	lcd.setCursor(0,1);
	lcd.print("SM:");
	lcd.print(soil);
	lcd. print(" HM:");
	lcd.print(humidity);
						   
}
							

When the Smart Composter is not displaying the actions it is undergoing, the LCD prints the levels of each parameter being monitored so the user always knows the status of the compost. Staying engaged with your compost pile even if you aren't physically maintaining it is an important part of the composting process!